Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
[SOLVED] newbie is going mad about if_section tag
hello forum,
i’ve gone through every piece of documentation about if_section tag, but to no avail. here is my problem:
the following code does not append the desired class to the list-item:
<txp:if_section name='<txp:section />'> class="trail"</txp:if_section>
instead it simply outputs class=“trail” to the frontend together with the active section:
class=“trail” Section
this is my first textpattern project and i’m going mad about this. can you help a newbie please?
regards
Last edited by totoff (2011-04-21 04:38:26)
Offline
Re: [SOLVED] newbie is going mad about if_section tag
Usually you use this in conjunction with txp:section_list
and it will output the code on the item in the section list that corresponds to the section currently showing in your browser, e.g.
<txp:section_list wraptag="ul" break=""">
<li<txp:if_section name='<txp:section />'> class="trail"</txp:if_section>><txp:section title="1" link="1" /></li>
</txp:section_list>
If you just want to apply the class for a specific section use:
<li<txp:if_section name="my-section-name"> class="trail"</txp:if_section>>...</li>
Is that what you meant?
TXP Builders – finely-crafted code, design and txp
Offline
Re: [SOLVED] newbie is going mad about if_section tag
thanks jakob
i would like to highlight the currently active section in order to style it via css.
however, i have not nested it into <li> tag as in your example. instead i receive the <li> from the break="li"
attribute of the section_list tag. may this cause the problem? in other words: do i always have to use the if_section tag inside a list-item?
edit:
here is the whole form i’m working on:
<txp:section_list active_class="active" include_default="0" sections="Projekte, Themen, Profil, Kontakt" wraptag="ul" break="li">
<txp:if_section name="projekte"> class="trail"</txp:if_section>
<txp:section link="1" title="1" />
<txp:if_section name='<txp:section />'>
<txp:article_custom section='<txp:section />' wraptag="ul" break="li">
<txp:if_article_id>›</txp:if_article_id>
<txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>
</txp:if_section>
</txp:section_list>
Last edited by totoff (2011-04-20 17:21:12)
Offline
Re: [SOLVED] newbie is going mad about if_section tag
i have not nested it into <li> tag as in your example. instead i receive the <li> from the break=“li” attribute of the section_list tag. may this cause the problem?
Yes, that would be the reason. It doesn’t know that it should be attaching it to the li
, so in your code, it probably appends the class after the closing bracket of the <li>
which would explain why it will then display on screen. txp:section_list
does have an active_class
attribute, which you’re using (or trying to use), but according to the docs it only works where the tag is a single tag, i.e. not a container and not with a form, so that doesn’t help in your case either.
If you make wraptag="ul" break=""
and include the li in your contained output as I outlined above or as in Example 3 in the docs, it should work as desired.
TXP Builders – finely-crafted code, design and txp
Offline
Re: [SOLVED] newbie is going mad about if_section tag
good morning jakob,
thank you very much. finally this has solved the problem. i was not aware that txp-tags can be nested in the attribute section of a html-tag! now i (hopefully) have taken a major step forward in my understanding of textpattern.
just to note: you also did nest the txp:section
tag as an attribute to the <li>
tag in your example. this has led to kind of a breadcrumb navigation. i did not follow this advice but instead made the following code:
<li<txp:if_section name='<txp:section />'> class="trail"</txp:if_section>><txp:section link="1" title="1" /></li>
thanks again, that was very helpfull!
Offline