Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#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

#17 2008-03-06 00:09:39

dl33
Member
Registered: 2006-06-17
Posts: 192
Website

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

#19 2008-03-06 12:14:51

dl33
Member
Registered: 2006-06-17
Posts: 192
Website

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

#21 2008-03-07 23:32:43

dl33
Member
Registered: 2006-06-17
Posts: 192
Website

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

#23 2008-03-18 21:37:32

dl33
Member
Registered: 2006-06-17
Posts: 192
Website

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 &nbsp 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>&nbsp;</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

#24 2008-03-18 21:47:56

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

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>&nbsp;</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

#25 2008-03-18 22:06:57

dl33
Member
Registered: 2006-06-17
Posts: 192
Website

Re: Plugin search: nested section & article list

Sweet, thanks… A lot simpler than I thought it was… Now how can I reflect this change in the URL? I moved all the articles into one section “Content” so the url now reads /de/content/test-article (I am using the Multi Language Plugin.)

Preferably I would like the URL to be something along the lines of /de/category-name/test-article . Is this possible or do I simply have to live with what I have now?

Offline

#26 2008-03-19 00:42:46

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Plugin search: nested section & article list

If you want use categories, the you need some link plugin, gbp_permanent_links as Textpattern doesn’t handle category based clean urls. TXP should, but clean urls were never actually finnished. In the core there is traces of a /category/title rule, but it’s not working, coz it’s only ghost from old times :)

Last edited by Gocom (2008-03-19 00:43:49)

Offline

Board footer

Powered by FluxBB