Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: Plugin search: nested section & article list
I took the <txp:output_form form="menu_li" />
out and the issue seems to be solved, except that everything goes bonkers,-) Could I use two if_different_tags
?
Offline
#14 2008-03-05 22:52:35
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Plugin search: nested section & article list
Try moving the output_form tag to before <txp:if_different>
.
Offline
Re: Plugin search: nested section & article list
Nope, that doesn’t work either. My idea with two <txp:if_different>
’s also doesn’t do the trick.
Offline
#16 2008-03-05 23:07:40
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Plugin search: nested section & article list
No, I didn’t think it would :( As far as I know it is not possible to get nested lists to work properly with if_different. You always end up with one or more closing list tags at the beginning of the list. I have used workarounds like this:
<txp:if_first_article>
<li style="display:none"><ul style="display:none">
<li style="display:none"></li> <!-- not sure if this second line is actually needed for validation? -->
</txp:if_first_article>
<txp:if_different>
</ul>
</li>
<li>
<txp:section title="1" />
<ul>
</txp:if_different>
<li><txp:permlink><txp:title /></txp:permlink></li>
<txp:if_last_article>
</ul>
</li>
</txp:if_last_article>
Offline
Re: Plugin search: nested section & article list
thanks, Ill try that tomorrow and let you know how it goes.
Offline
#18 2008-03-06 00:36:30
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: Plugin search: nested section & article list
Ok dl33,
as I said I knew it was going to be tricky… anyway here is my last try: at least in my head it should work now (hope not to be too optimistic)
in your page form put
<ul><txp:article_custom form="my_form" sort="section" /></ul>
in your article form (my_form)
<txp:if_different>
<txp:output_form form="first_article" />
<txp:section /><ul>
</txp:if_different>
<li><txp:permlink><txp:title /></txp:permlink></li>
<txp:if_last_article>
</ul></li>
</txp:if_last_article>
…and in your “first_article” form
<txp:if_first_article>
<li>
<txp:else />
</ul></li><li>
</txp:if_first_article>
Offline
Re: Plugin search: nested section & article list
Thanks a lot guys. In the end I ended up using Els’ workaround…
However, have a look what I just found http://textbook.textpattern.net/wiki/index.php?title=Txp:if_different#Example_2:_Build_an_indented_list_of_article_titles_grouped_by_section
I think this could have been done a lot simpler…
EDIT: Nope, you get the same problem with the double sections… I’ll just stick with the extra ul at the front… Thanks, guys.
Last edited by dl33 (2008-03-06 12:28:59)
Offline
#20 2008-03-06 16:20:09
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Plugin search: nested section & article list
dl33 wrote:
However, have a look what I just found (…) I think this could have been done a lot simpler…
As long as you don’t need list tags around the field that is inside the if_different tags, there is no problem. But ever since the if_different tag was introduced I have been trying to get it working with lists, and I never found a way other than the workaround I mentioned above.
Offline
Re: Plugin search: nested section & article list
I am using Els’ code now: (It works great:-) Thanks)
<txp:if_first_article>
<li style="display:none"><ul style="display:none">
<li style="display:none"></li> <!-- not sure if this second line is actually needed for validation? -->
</txp:if_first_article>
<txp:if_different>
</ul>
</li>
<li>
<txp:section title="1" />
<ul>
</txp:if_different>
<li><txp:permlink><txp:title /></txp:permlink></li>
<txp:if_last_article>
</ul>
</li>
</txp:if_last_article>
Is it possible to exclude one or more sections from being listed in this menu?
Last edited by dl33 (2008-03-07 23:33:28)
Offline
#22 2008-03-08 00:38:20
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: Plugin search: nested section & article list
You can specify the sections you want to include in the article_custom tag adding a “section” attribute followed by a comma separated list of sections. like this:
<txp:article_custom form="my_form" sort="section" section="section1, section2, section3" />
If you really need to exclude some sections you should operate in your article form embracing it in a “if_article_section” tag like this:
<txp:if_article_section name="section4, section5">
<txp:else />
<txp:if_first_article>
<li style="display:none"><ul style="display:none">
<li style="display:none"></li> <!-- not sure if this second line is actually needed for validation? -->
</txp:if_first_article>
<txp:if_different>
</ul>
</li>
<li>
<txp:section title="1" />
<ul>
</txp:if_different>
<li><txp:permlink><txp:title /></txp:permlink></li>
<txp:if_last_article>
</ul>
</li>
</txp:if_last_article>
</txp:if_article_section>
Offline
Re: Plugin search: nested section & article list
Hi again, I have to adapt the code ever so slightly since my client had some new requirements. I am wondering whether there is a way to use a similar approach with categories instead of sections. (The URL should then be /category/title/) What do I have to change in order to get this working?
Another problem is that the category/section name should not actually be visible. I tried putting  
in the place of <txp:section title="1" />
but that only produces one big list instead of three smaller ones.
The code I have now is:
<txp:if_first_article><li style="display:none"><ul><li> </li></txp:if_first_article>
<txp:if_different></ul></li><li><txp:section title="1" /><ul></txp:if_different>
<li><txp:permlink><txp:title /></txp:permlink></li>
<txp:if_last_article></ul></li></txp:if_last_article>
and actually referencing this form:
<ul id="menu"><txp:article_custom form="menu" sort="section asc" section="1_was,2_wer,3_wann" /></ul>
What do I have to change in order to get this working with categories and without the category names?
The code produces would look like this:
<ul>
<li><ul><!--First Category-->
<li>Title</li>
<li>Title</li>
</ul></li>
<li><ul><!--Second Category-->
<li>Title</li>
<li>Title</li>
</ul></li>
</ul>
Offline
Re: Plugin search: nested section & article list
Same code than yours, but edit it that it looks like:
<txp:if_first_article><li style="display:none"><ul><li> </li></txp:if_first_article><txp:if_different></ul></li><li><!-- <txp:category1 title="1" /> --><ul></txp:if_different><li><txp:permlink><txp:title /></txp:permlink></li><txp:if_last_article></ul></li></txp:if_last_article>
<ul id="menu"><txp:article_custom form="menu" sort="category1 asc" section="1_was,2_wer,3_wann" /></ul>
Offline