Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-10-12 23:50:09

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

if_individual_article vrs. if_section

I would like to know the opinions of more experienced developers on this:
Should if_individual_article be used instead of if_section for displaying section specific articles?
Is if_section more for non-article content?

Last edited by kvnmcwebn (2008-10-12 23:52:46)


its a bad hen that wont scratch itself.
photogallery

Offline

#2 2008-10-13 00:44:28

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

Re: if_individual_article vrs. if_section

I’m not sure if I understand the question, but if_individual article is the “opposite” of if_article_list.
If_section is just for testing if you are on a particular section (it doesn’t care if you are on an article-list or individual-article context).
In other words, if_section doesn’t test if you are in a section, because you are always on a section (even the home page is a section, the _default_section).


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#3 2008-10-13 00:49:37

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

Re: if_individual_article vrs. if_section

hi, sorry if that didnt make much sense-Ive been reading the textpattern manual and need to clarify this. I know that if_section tests for a section but doesn’t the <txp:article/> tag do that also, when used with if_individual_article??


its a bad hen that wont scratch itself.
photogallery

Offline

#4 2008-10-13 02:29:00

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: if_individual_article vrs. if_section

The article tag doesn’t really test, the functionality runs much deeper than a conditional tag does. When article tags are set to a section they return articles assigned to that section, they also set urls and variables that other tags depend on for section sensitivity as a context.
The if_section tag is a true conditional in a TXP sense and simply tests for a particular section being set and returns contained content accordingly.
if_individual_article is also a conditional in the way it behaves and returns true or false according to whether or not a single article (according to the url with an article id contained in it) is being display.

To answer your question, I use it control or select both specific content and in some cases select article tags with different attribute settings – not really a yes or no response there.

Last edited by rsilletti (2008-10-13 02:33:11)

Offline

#5 2008-10-13 13:01:58

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

Re: if_individual_article vrs. if_section

Right my objective is to cut down the number of pages.
So would the following make sense?:

Non article type content:

<txp_if_section name="section-one"> <body id="section-one"> <txp:else /> <txp_if_section name="section-two"> <body id="section-two"> <txp:else /> <txp_if_section name="section-three"> <body id="section-three"> <txp_if_section />

Then for an articles:
<txp:if_individual_article> <txp:article form="someform" /> <txp:else /> <txp:article limit="1"> </txp:if_individual_article>

Last edited by kvnmcwebn (2008-10-13 13:03:07)


its a bad hen that wont scratch itself.
photogallery

Offline

#6 2008-10-13 13:52:58

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: if_individual_article vrs. if_section

kvnmcwebn wrote:

<txp_if_section name="section-one"> <body id="section-one"> <txp:else /> <txp_if_section name="section-two"> <body id="section-two"> <txp:else /> <txp_if_section name="section-three"> <body id="section-three"> <txp_if_section />

You can do just this: <body id="<txp:section />">, or, if you don’t want to give the front page’s body an id: <txp:if_section name=""><body><txp:else /><body id="<txp:section />"></txp:if_section>.

Then for an articles:
<txp:if_individual_article> <txp:article form="someform" /> <txp:else /> <txp:article limit="1"> </txp:if_individual_article>

Just <txp:article form="someform" listform="someotherform" limit="n" /> will do this:

  • in individual article mode: display the requested article with form ‘someform’
  • in article list mode: display a list of n article(s) using form ‘someotherform’ (n can also be 1)

Offline

#7 2008-10-13 13:57:47

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

Re: if_individual_article vrs. if_section

Thanks!


its a bad hen that wont scratch itself.
photogallery

Offline

#8 2008-10-13 23:28:11

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

Re: if_individual_article vrs. if_section

If i do this <txp:article form=“someform” listform=“someotherform” limit=“n” />:

For displaying articles on the home/default section should I make a “home” category?


its a bad hen that wont scratch itself.
photogallery

Offline

#9 2008-10-14 00:19:23

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

Re: if_individual_article vrs. if_section

If you want the articles from some particular section to display on front page (home/default page) you can set the option “On front page” to “yes”, on Presentation -> Sections.
This will allow you to display “live” articles for a particular section on the homepage article flow.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#10 2008-10-14 11:24:43

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

Re: if_individual_article vrs. if_section

Els wrote:

Just <txp:article form="someform" listform="someotherform" limit="n" /> will do this:

  • in individual article mode: display the requested article with form ‘someform’
  • in article list mode: display a list of n article(s) using form ‘someotherform’ (n can also be 1)

Hi,

Im stuck again. If i want one section to display a list of articles but use the same page as the other sections that are displaying articles how do i do that? So in this case do i would use if_individual article right? It looks like you have the listform and form defined in the same article tag, and thats got me a wee bit confused.

-best
kevin


its a bad hen that wont scratch itself.
photogallery

Offline

#11 2008-10-14 14:01:22

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: if_individual_article vrs. if_section

kvnmcwebn wrote:

If i want one section to display a list of articles but use the same page as the other sections that are displaying articles how do i do that?

Not sure if I understand you, but if you assign the same page to all sections (in Presentation > Sections), they will all use that page. The article tag I posted will automatically display articles from the right section (depending on the URL). So site.com/section-1/ will display a list of articles in section ‘section-1’ using the form specified with the listform attribute. site.com/section-1/article-title-1 will display article ‘article-title-1’ using the form specified with the form attribute.

Or did you mean that you want to display articles from more than one section in one list? In that case you need <txp:article_custom section="section-1,section-2" form="yourlistform" />.

<txp:article /> is context sensitive, meaning that what it displays depends on the ‘environment’ (the URL in fact), so you should never need to use if_individual_article or if_section and the like. This also means that you cannot use it to display articles from other sections on a particular section page.
<txp:article_custom /> on the other hand has to be told what to display. This gives you the freedom to display whatever you want wherever you want ;)

Last edited by els (2008-10-14 14:07:34)

Offline

#12 2008-10-14 14:46:10

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

Re: if_individual_article vrs. if_section

Wait i see now. if theres one article it uses article form, if theres two articles in the section it uses listform…. i didnt get enough sleep… thanks els.


its a bad hen that wont scratch itself.
photogallery

Offline

Board footer

Powered by FluxBB