Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-02-14 17:45:37

tillinghast
New Member
Registered: 2004-11-12
Posts: 4

if_section works on all but one section

I really don’t know what I’m doing wrong here. The code below works for all sections but “about”. Any suggestions?

<code>
<txp:if_section name=“about”>
<txp:article_custom section=“about” sortby=“Title” sortdir=“asc” form=“section_article_list” />
</txp:if_section>
<txp:if_section name=“services”>
<txp:article_custom section=“services” sortby=“Title” sortdir=“asc” form=“section_article_list” />
</txp:if_section>
<txp:if_section name=“locations”>
<txp:article_custom section=“locations” sortby=“Title” sortdir=“asc” form=“section_article_list” />
</txp:if_section>
<txp:if_section name=“resources”>
<txp:article_custom section=“resources” sortby=“Title” sortdir=“asc” form=“section_article_list” />
</txp:if_section>
</code>

Offline

#2 2006-02-14 19:13:54

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,122
Website GitHub Mastodon Twitter

Re: if_section works on all but one section

Do you have it to show in the front page?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#3 2006-02-14 19:46:14

tillinghast
New Member
Registered: 2004-11-12
Posts: 4

Re: if_section works on all but one section

Yes, this is on the default page and shows on the front page. Actually, I just remembered that I have everything wrapped in another <code><txp:if_section></code> tag:

<code>
<txp:if_section name=”“>
<h2>Sections</h2>
<p> <a href=”/about/”>About Oasis</a><br /> <a href=”/services/”>Services</a><br /> <a href=”/locations/”>Locations</a><br /> <a href=”/resources/”>Resources</a><br /> <a href=”#help”>Help</a><br />
</p>
<txp:else />
<h2><txp:section title=“1” link=“1” /></h2>
<p> <txp:if_section name=“about”> <txp:article_custom section=“about” sortby=“Title” sortdir=“asc” form=“section_article_list” /> </txp:if_section> <txp:if_section name=“services”> <txp:article_custom section=“services” sortby=“Title” sortdir=“asc” form=“section_article_list” /> </txp:if_section> <txp:if_section name=“locations”> <txp:article_custom section=“locations” sortby=“Title” sortdir=“asc” form=“section_article_list” /> </txp:if_section> <txp:if_section name=“resources”> <txp:article_custom section=“resources” sortby=“Title” sortdir=“asc” form=“section_article_list” /> </txp:if_section>
</p>
</txp:if_section>
</code>

Offline

#4 2006-02-14 20:10:36

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

Re: if_section works on all but one section

hi tillinghast

the problem is that you are nesting the same TXP tag (an if_section inside an if_section). That is not possible.
Let me explain:

you cant do :

<txp:if_section name="">
.blablablab..
<txp:else />
<txp:if_section name="xxxxx">
.blablablab.
</txp:if_section>
</txp:if_section>

So, you think that your “about” section is not working, but the truth is that the <code></txp:if_section>”</code> that is ‘closing’ your <code><txp:if_section name=“about”></code> is, in fact, closing the first <code><txp:if_section name=”“></code> and I would bet that this is the reason why your code snippet isnt working.

I think you can try the following code, and please, let me know if that works for you:

<txp:if_section name="">
<h2>Sections</h2>
<p>
<a href="/about/">About Oasis</a><br />
<a href="/services/">Services</a><br />
<a href="/locations/">Locations</a><br />
<a href="/resources/">Resources</a><br />
<a href="#help">Help</a><br />
</p>
<txp:else />
<h2><txp:section title="1" link="1" /></h2>
</txp:if_section>
<txp:if_section name="about,services,locations,resources">
<txp:article sortby="Title" sortdir="asc" form="section_article_list" />
</txp:if_section>

Last edited by maniqui (2006-02-14 20:12:32)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#5 2006-02-14 20:22:46

tillinghast
New Member
Registered: 2004-11-12
Posts: 4

Re: if_section works on all but one section

Ah, I see. <code><txp:if_section></code> conditional tags cannot be nested. Is this listed anywhere in the documentation? I assume this is the typical behavior, so all other conditional tags are not able to be nested either? Thank you very much for your help maniqui — here’s my final (working) code:

<code>
<txp:if_section name=”“>
<h2>Sections</h2>
<txp:else />
<h2><txp:section title=“1” link=“1” /></h2>
</txp:if_section>
<txp:if_section name=”“>
<p> <a href=”/about/”>About Oasis</a><br /> <a href=”/services/”>Services</a><br /> <a href=”/locations/”>Locations</a><br /> <a href=”/resources/”>Resources</a><br /> <a href=”#help”>Help</a><br />
</p>
</txp:if_section>
<txp:if_section name=“about”> <p> <txp:article_custom section=“about” sortby=“Title” sortdir=“asc” form=“section_article_list” /> </p>
</txp:if_section>
<txp:if_section name=“services”> <p> <txp:article_custom section=“services” sortby=“Title” sortdir=“asc” form=“section_article_list” /> </p>
</txp:if_section>
<txp:if_section name=“locations”> <p> <txp:article_custom section=“locations” sortby=“Title” sortdir=“asc” form=“section_article_list” /> </p>
</txp:if_section>
<txp:if_section name=“resources”> <p> <txp:article_custom section=“resources” sortby=“Title” sortdir=“asc” form=“section_article_list” /> </p>
</txp:if_section>
</code>

Offline

#6 2006-02-14 20:42:30

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

Re: if_section works on all but one section

Hi tillinghast

About nesting same tags, there is some info in this faq

It seems that there is a woraround for nesting same tags.

BTW, have you tried this short block of code

<txp:if_section name="about,services,locations,resources">
<txp:article sortby="Title" sortdir="asc" form="section_article_list" />
</txp:if_section>

instead of your large block

<txp:if_section name="about">
<p>
<txp:article_custom section="about" sortby="Title" sortdir="asc" form="section_article_list" />
</p>
</txp:if_section>
<txp:if_section name="services">
<p>
<txp:article_custom section="services" sortby="Title" sortdir="asc" form="section_article_list" />
</p>
</txp:if_section>
<txp:if_section name="locations">
<p>
<txp:article_custom section="locations" sortby="Title" sortdir="asc" form="section_article_list" />
</p>
</txp:if_section>
<txp:if_section name="resources">
<p>
<txp:article_custom section="resources" sortby="Title" sortdir="asc" form="section_article_list" />
</p>
</txp:if_section>

I think it should work, and make your form/page template shorter.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#7 2006-02-14 21:22:12

tillinghast
New Member
Registered: 2004-11-12
Posts: 4

Re: if_section works on all but one section

maniqui -

I don’t know why I was stuck on using <code><txp:article_custom /></code> — probably I thought that I needed to be specifying the section, but <code><txp:article /></code> does that automatically. You provided exactly what I needed.

Also, thanks for pointing me to the workaround. I’ll hold onto that for future reference.

Offline

Board footer

Powered by FluxBB