Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2017-09-16 09:24:52
- bashirnoori
- Member
- From: Afghanistan
- Registered: 2012-10-02
- Posts: 75
article_custom dynamic in different way
I want to list the articles title in the following format:
<li>
the title of article 1
the title of article 2
the title of article 3
</li>
<li>
the title of article 4
the title of article 5
the title of article 6
</li>
...
I’m trying in the following codes, but it’s not dynamic and professional way.
<li>
<txp:article_custom limit="3">
<txp:title />
</txp:article_custom>
</li>
<li>
<txp:article_custom offset="3" limit="3">
<txp:title />
</txp:article_custom>
</li>
...
Offline
Re: article_custom dynamic in different way
There are probably multiple ways of doing that, and if your intention is just for layout purposes, you might want to simply wrap every title in an <li>…</li>
and use CSS nth-child
/ nth-of-type
to achieve the desired layout. That’s also most flexible for responsive layouts, where you may want to break every second rather than every third title, etc.
However, to come back to your specific example, you could do that with a txp variable and adi_calc. Something like this:
<txp:variable name="group-counter" value="0" />
<ul>
<li>
<txp:article_custom section="your-section" limit="9999">
<txp:adi_calc name="group-counter" add="1" />
<txp:title />
<txp:if_variable name="group-counter" value="3">
</li>
<li>
<txp:variable name="group-counter" value="0" />
</txp:if_variable>
</txp:article_custom>
</li>
</ul>
That should advance a counter and on every third counter add your tags and reset the counter again.
TXP Builders – finely-crafted code, design and txp
Offline
Offline