Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-03-15 14:56:01

vurt
Member
Registered: 2010-10-22
Posts: 50

Displaying articles in groups

I’m interested in using something like the jQuery Cycle plugin to paginate articles in groups of 3.

I’ve done this before when the number of articles is fixed and/or manageable by doing:

<div id=“cycle”>

<div><txp:article limit=“3” /></div>
<div><txp:article limit=“3” offset=“3” /></div>
<div><txp:article limit=“3” offset=“6” /></div> etc.

</div>

But now I have a situation where the article list will grow immeasurably. So I need a way to dynamically generate the groups and auto-increment the offset.

Could <txp:if_different /> be used for this purpose?

Offline

#2 2011-03-15 17:49:41

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

Re: Displaying articles in groups

Though I’ve never needed/used it: zem_nth could be of massive help here, inserting the closing and the opening divs into your article form after three iterations. You’d only need one article tag.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#3 2011-03-15 17:59:26

vurt
Member
Registered: 2010-10-22
Posts: 50

Re: Displaying articles in groups

Oh yes. I could use that.

Looks like thresholdstate.com is currently inactive(?)

Anybody know where I can download zem_nth?

Offline

#4 2011-03-15 18:08:13

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,257
Website GitHub Mastodon Twitter

Re: Displaying articles in groups

vurt wrote:

Anybody know where I can download zem_nth?

Hi vurt,

Pasted it in the plugin’s thread


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#5 2011-03-15 18:14:33

vurt
Member
Registered: 2010-10-22
Posts: 50

Re: Displaying articles in groups

Thank you!

Offline

#6 2011-03-15 20:17:56

vurt
Member
Registered: 2010-10-22
Posts: 50

Re: Displaying articles in groups

Well you would think that zem_nth would work, but as has been mentioned elsewhere, a problem arises if the article count is not divisible by 3 (in this case I need groups of 3 articles.) If the article count is not divisible by 3 the “leftovers” don’t get closed.

Offline

#7 2011-03-15 20:56:20

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

Re: Displaying articles in groups

I think adi_calc in variable/if_variable tags might do the maths.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#8 2011-03-15 21:02:54

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: Displaying articles in groups

This post may be of use.

Offline

#9 2011-03-15 21:03:03

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: Displaying articles in groups

Have you looked at Example 3: Build a table of article titles on the txp_variable page? There is a way to do this sort of thing without a plugin.

I used my own version of it for the Themes Page at CMS Styles. I am not sure exactly what you are going for but if you put some code in your main template like:

<txp:variable name="trigger" value="1" />
<txp:article form="my_complicated_article_form" />

and put something like this in your form:

<txp:if_variable name="trigger" value="3">

      [do something and close it]

      <txp:variable name="trigger" value="1" />

<txp:else />

      [do something]

<txp:if_variable name="trigger" value="2">
      <txp:variable name="trigger" value="3" />
</txp:if_variable>

<txp:if_variable name="trigger" value="1">
      <txp:variable name="trigger" value="2" />
</txp:if_variable>

</txp:if_variable>

Offline

#10 2011-03-15 21:16:50

vurt
Member
Registered: 2010-10-22
Posts: 50

Re: Displaying articles in groups

Wow gomedia and michaelkpate those are both great references. Thank you.

Offline

Board footer

Powered by FluxBB