Textpattern CMS support forum

You are not logged in. Register | Login | Help

#11 2019-11-03 18:37:49

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,325
Website

Re: [Solved] Category list and this_section TXP 4.8-dev

Thanks both ;)

I get what I expect adding a little amendment to Oleg’s advice:

<txp:variable name="categories">
    <txp:article_custom section='<txp:section />' break="," limit="99">
        <txp:category1 />, <txp:category2 />
    </txp:article_custom>
</txp:variable>

The included <txp:section /> is needed to filter the current section displayed.

Last edited by Pat64 (2019-11-03 18:39:20)


Patrick.

Github | CodePen | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#12 2019-11-03 22:13:27

etc
Developer
Registered: 2010-11-11
Posts: 3,427
Website

Re: [Solved] Category list and this_section TXP 4.8-dev

Pat64 wrote #319916:

The included <txp:section /> is needed to filter the current section displayed.

Glad you got it working, though valueless section attribute should have produced the same result.

Offline

#13 2019-11-04 06:44:26

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,325
Website

Re: [Solved] Category list and this_section TXP 4.8-dev

I’m working on a new theme where I need to know what is the “on frontpage” section:

<txp:variable name="front" escape="lower,trim">
<txp:section_list limit="1" sort="on_frontpage desc" break=""><txp:section /></txp:section_list>
</txp:variable>

This above offer to me the capacity to avoid a twice acces to a section shown on the main page of the site:

<ul class="u tc cb">
		<li class="h"><h4>Languages<i class="x">:</i></h4></li>
		<li class="<txp:if_section name=',<txp:variable name="front" />'>a</txp:if_section>"><a href="<txp:site_url />"><txp:variable name="front" /></a></li>
<txp:section_list exclude='<txp:variable name="front" />' sort="name asc" break=""><txp:evaluate query='string-length("<txp:section />") < 3'>
		<li class="<txp:if_section name='<txp:section />'>a</txp:if_section>"><a href="<txp:site_url /><txp:section />"><txp:section escape="upper" /></a></li></txp:evaluate></txp:section_list>
</ul>

Further more, with your help, I got a perfect list of all the categories (as keywords list) associated to the current section of the site:

<txp:variable name="categories">
    <txp:article_custom section='<txp:if_section name=""><txp:variable name="front" /><txp:else /><txp:section /></txp:if_section>' break="," limit="99">
        <txp:category1 />, <txp:category2 />
    </txp:article_custom>
</txp:variable>

Finally, I can create a language menu for conveniences:

<ul class="u tc cb">
	<li class="h"><h4>Languages<i class="x">:</i></h4></li>
	<li class="<txp:if_section name=',<txp:variable name="front" />'>a</txp:if_section>"><a href="<txp:site_url />"><txp:variable name="front" /></a></li>
<txp:section_list exclude='<txp:variable name="front" />' sort="name asc" break=""><txp:evaluate query='string-length("<txp:section />") < 3'>
	<li class="<txp:if_section name='<txp:section />'>a</txp:if_section>"><a href="<txp:site_url /><txp:section />"><txp:section escape="upper" /></a></li></txp:evaluate></txp:section_list>
</ul>

And, why not, the hreflang links:

<txp:section_list sort="name asc" break=""><txp:evaluate query='string-length("<txp:section />") < 3'>
<link rel="alternate" hreflang="<txp:section />-<txp:section />" href="<txp:site_url /><txp:section />"></txp:evaluate></txp:section_list>
<link rel="alternate" hreflang="x-default" href="<txp:site_url />">

Last edited by Pat64 (2019-11-04 07:12:06)


Patrick.

Github | CodePen | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

Board footer

Powered by FluxBB