Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: rah_repeat // Split and repeat.
Rah_repeat v0.8 is out. This updated concentrates making things easier for all of us. Changelog:
- Fixed: made the
sort
attribute’s direction optional. - Added:
exclude
can now take and exclude empty strings (""
) and zeros (0
). - Added:
range
attribute. Allows generating automated lists (range="min, max, step"
). - Added:
assign
attribute. Allows extracting values as variables. - Added:
escape
attribute to<txp:rah_repeat_value />
. - Added: Support for natural ordering (
sort="natural"
). - Changed: Now
trim
is enabled by default. Previously values weren’t trimmed from white-space by default. - Changed: Renamed
locale
sorting option toLOCALE_STRING
. - Changed: Order can be reversed with out re-sorting by using
sort="desc"
. - Now requires PHP 5.2 (or newer).
See the release article for introduction to the new features, or jump directly to the docs and download here.
Offline
Re: rah_repeat // Split and repeat.
I’m getting a weird issue with range (txp 4.4.1 and php 5.3.10 on wamp): whatever values I use, e.g.
<txp:rah_repeat range="4,100" wraptag="p" break=",">
<txp:rah_repeat_value />
</txp:rah_repeat>
or
<txp:rah_repeat range="a,z" wraptag="p" break=",">
<txp:rah_repeat_value />
</txp:rah_repeat>
it outputs 0 , 1 , ... , 10
.
Offline
Re: rah_repeat // Split and repeat.
Thanks for the report, Oleg. It’s fixed. It was the array_merge I used to make sure there is a third parameter set. Well, It does recalculate numeric indexes.
Offline
Re: rah_repeat // Split and repeat.
Rah_repeat version v0.8.1 is out. Fixes the range issue.
Offline
Re: rah_repeat // Split and repeat.
Is there any way to sort by variable with rah_repeat? I’m not 100% sure that I understand rah_repeat’s sort features. In the example below, each data set is a listing and one of the value/variables in each set is a date/time (or lack thereof). I would like to order each “listing” by this date/time value if possible.
Here is a simplified version of my code:
<h1>Recently Updated Listings:</h1>
<txp:variable name="all_listings" value='<txp:article_custom section="section_name"><txp:custom_field name="customfieldname" escape="" /></txp:article_custom>' />
<txp:rah_repeat value='<txp:variable name="all_listings" />' delimiter="~||~">
<txp:rah_repeat value='<txp:rah_repeat_value />' delimiter="~|~" assign="field1, field2, field3, update_date" sort="I don't think I can use sort to do want I'd like to do?"/>
<txp:if_variable name="update_date" value=""><txp:else /><li><txp:variable name="field1" /></li>
</txp:rah_repeat>
Each listing contains 4 values as follows:
field1~|~field2~|~field3~|~update_date~||~
Example content (first set does not contain an update_date):
title field1~|~description field2~|~something else field3~|~~||~another listing title field1~|~this other listing description field2~|~something else for this listing field3~|~2012/10/16 8:51:37~||~the listing title field1~|~the listing desc field2~|~something else for this listing field3~|~2012/06/11 12:20:37~||~another title field1~|~another description field2~|~another something field3~|~2011/02/14 3:47:15~||~
Thanks in advance for any thoughts or suggestions!
Offline
Re: rah_repeat // Split and repeat.
Maybe it will be easier to sort listings by SUBSTRING_INDEX in <txp:article_custom />
?
Offline
Re: rah_repeat // Split and repeat.
Thanks for the suggestion, etc. I’m going to have to study up on SUBSTRING_INDEX.
Offline
Re: rah_repeat // Split and repeat.
v1.0.0 released. Changes:
- Fixed: Return a empty string instead of NULL byte on halt.
- Added:
form
attribute. - Added:
index
attribute to therah_repeat_value
tag. - Now requires Textpattern 4.5.0 or newer.
Offline
#45 2016-04-13 19:37:58
- lazlo
- Member
- Registered: 2004-02-24
- Posts: 110
Re: rah_repeat // Split and repeat.
Hi Jukka
This is a wonderful plugin and I use it to great effect but …
First Problem.
Do you think rah_repeat will get a proper “Alpha” sort where Lower case “b” and Upper case “B” are treated the same? As it stands now the “string” sorts all upper case first, then lower case. Is there another solution?
Second Problem.
I am having a bit of problem with a single white space character being inserted during rah_repeat.
This code:
<txp:rah_repeat value='<txp:custom_field name="Contributors_Group"/>' delimiter="~||~">
<txp:rah_repeat value='<txp:rah_repeat_value />' delimiter="~|~" assign="onix_code,contributor_role,contributor_full_name,contributor_full_name_reversed, contributor_name_before_key,contributor_key_name,contributor_latin_1,contributor_URL, contributor_country"/>
<txp:if_variable name="onix_code" value="A02">
<txp:variable name="contributor_full_name"/></txp:if_variable>
</txp:rah_repeat>
</txp:rah_repeat>
When iterated over this data set (or any data set like this).
A01~|~By~|~John MacLachlan Gray~|~Gray, John MacLachlan~|~Gray~|~John MacLachlan~|~John MacLachlan Gray~|~john-maclachlan-gray~|~CA~||~
A02~|~With~|~Eric Peterson~|~Peterson, Eric~|~Peterson~|~Eric~|~Eric Peterson~|~eric-peterson~|~CA~||~
The variable <txp:variable name=“contributor_full_name”/> shows “ Eric Peterson” not “Eric Peterson”
It seems that you are adding a white space seperator for list purposes and it is at the front?
Third Problem (related to Second Problem I imagine).
If I insert a break=“br” into
<txp:rah_repeat break="br" value='<txp:custom_field name="Contributors_Group"/>' delimiter="~||~">
The result is “<br /> Eric Peterson” not “Eric Peterson<br />.
The final name in a list that iterates over many of these datasets doesn’t have a <br /> after it but the first one has a <br /> precede it.
Last edited by lazlo (2016-04-13 20:12:48)
Offline
Re: rah_repeat // Split and repeat.
Jukka gone.
Gone, daddy… gone.
Offline
#47 2016-04-14 05:38:06
- lazlo
- Member
- Registered: 2004-02-24
- Posts: 110
Re: rah_repeat // Split and repeat.
Offline
Re: rah_repeat // Split and repeat.
Oh, does that mean rah plugins are orphaned?
Kind of. They all / mostly work and they are pretty invaluable but Jukka’s been AWOL for a long while on seemingly all internet channels with his gocom handle. His site went down a while ago with a server/txp-version error, then returned after some weeks, so someone must have repaired something…
I am having a bit of problem with a single white space character being inserted during rah_repeat
Re: your question: Does your space disappear if you don’t have a newline in there? There is the trim="1"
attribute, but that is set by default and I think applies only to the values in the attribute and not the output. If you have no luck with that, you can trim the output itself “manually” by wrapping your output in <txp:smd_wrap>…</txp:smd_wrap>
or <txp:rah_function call="trim">…</txp:rah_function>
.
The result is “<br /> Eric Peterson” not “Eric Peterson<br />.
The <br>
appearing before and not after your value has – I think – to do with the fact that you have the break value in the outer rah_repeat
tag. That will add a <br>
at the ~||~
delimiter, and that comes before your if_variable
tag does its checking… and as you are using rah_repeat_value
as an attribute for the nested instance, it does trigger the repeat counter and therefore outputs a <br>
.
TXP Builders – finely-crafted code, design and txp
Offline