Hello folks!
Some days ago it was needed to show on a page only X items from a "repeatable" region, and to make my day worse, all X items should start from position Y (for example to show 3 items from position 2, that should display items 2, 3 and 4). So I decided to mod a little bit the "repeatable" addon. This modded add-on introduces 2 new parameters:
startfrom which indicates index from which the rows will be displayed and
howmany which set the number of rows to be displayed.
A quick example will be like this:
Definition of repeatable region (nothing new here)
and the code used to display only 5 elements (using those 2 new tags)
which will display only rows C, D, E, F, G - assuming you've have rows A to I already entered in admin.
To install this addon, simply replace the original /couchcms/addons/repeatable/repeatable.php with the one from archive attached to this post. Hoping you'll find it useful, please note I'm not a hardcore PHP coder, so if someone can make it better, feel free to do so.
P.S. I'm not native english speaker, but I hope I was clear enough about how to use this mod.
Some days ago it was needed to show on a page only X items from a "repeatable" region, and to make my day worse, all X items should start from position Y (for example to show 3 items from position 2, that should display items 2, 3 and 4). So I decided to mod a little bit the "repeatable" addon. This modded add-on introduces 2 new parameters:
startfrom which indicates index from which the rows will be displayed and
howmany which set the number of rows to be displayed.
A quick example will be like this:
Definition of repeatable region (nothing new here)
- Code: Select all
<cms:repeatable name='test_repeat' label='Test'>
<cms:editable type='text' name='value' label='Value' col_width='250' />
</cms:repeatable>
and the code used to display only 5 elements (using those 2 new tags)
- Code: Select all
<cms:show_repeatable 'test_repeat' startfrom='3' howmany='5' >
<cms:show value />
</cms:show_repeatable>
which will display only rows C, D, E, F, G - assuming you've have rows A to I already entered in admin.
To install this addon, simply replace the original /couchcms/addons/repeatable/repeatable.php with the one from archive attached to this post. Hoping you'll find it useful, please note I'm not a hardcore PHP coder, so if someone can make it better, feel free to do so.
P.S. I'm not native english speaker, but I hope I was clear enough about how to use this mod.