Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-05-05 11:45:56

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

conditional statement, is this the best way.

Would this work?

I need to get the following to display articles with one of either two forms depending on the category.

<txp:if_category name=“multiple”> <txp:if_individual_article> <txp:article limit=“1” form=“multiple_entry” section=“web” /> <txp:else /> <txp:article limit=“1” form=“blog_entry” status=“sticky” section=“web” /> </txp:if_individual_article> <txp:else /> <txp:if_individual_article> <txp:article limit=“1” form=“single_entry” section=“web” /> <txp:else /> <txp:article limit=“1” form=“single_entry” status=“sticky” section=“web” /> </txp:if_individual_article> </txp:if_category>

-thanks in advance
kevin

p.s. here is a link if you’d like to see the formatted code

http://www.mcmonagledesign.com/images/format.gif

Last edited by kvnmcwebn (2009-05-05 11:53:10)


its a bad hen that wont scratch itself.
photogallery

Offline

#2 2009-05-05 12:58:30

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: conditional statement, is this the best way.

kvnmcwebn wrote:

Would this work?

  <txp:if_category name="multiple">
       <txp:if_individual_article>
          <txp:article  limit="1" form="multiple_entry" section="web" />
      <txp:else />
          <txp:article limit="1" form="blog_entry" status="sticky" section="web" />
      </txp:if_individual_article>
   <txp:else />      
         <txp:if_individual_article>
         <txp:article  limit="1" form="single_entry" section="web" />
   <txp:else />
         <txp:article limit="1" form="single_entry" status="sticky" section="web" />
         </txp:if_individual_article>
    </txp:if_category>

It may work or not (i.e. it may output the desired output), although I think there are some “conceptual” errors on your code (by the way, you can use bc. to put formatted code here at the forum, quote my post to see how I did it).

Back to the code.
If I understand what you are trying, the following snippet may be one possible solution

<txp:if_individual_article>
<!-- if we are in an individual article -->
  <txp:if_article_category name="multiple">
  <!-- and if that article category is "multiple" -->
    <txp:article  limit="1" form="multiple_entry" section="web" />
  <txp:else />
  <!-- else (that article category isn't "multiple") -->
    <txp:article  limit="1" form="single_entry" section="web" />
  </txp:if_article_category>
<txp:else />
<!-- if we aren't in an individual article, we are in an article list -->
  <txp:article limit="1" form="blog_entry" status="sticky" section="web" />
</txp:if_individual_article>

La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#3 2009-05-05 13:15:20

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: conditional statement, is this the best way.

hi maniqui,

  <txp:if_article_category name="multiple">

I think thats what i was looking for. I will try it now. thanks a mill.
-kevin


its a bad hen that wont scratch itself.
photogallery

Offline

#4 2009-05-05 13:29:46

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: conditional statement, is this the best way.

Hi Maniqui, that works perfectly. Also thanks for the detailed comments. I see were the errors were in my understanding. Much appreciated.


its a bad hen that wont scratch itself.
photogallery

Offline

Board footer

Powered by FluxBB