Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#37 2012-08-24 23:09:21

Gocom
Plugin Author
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

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 to LOCALE_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

#38 2012-08-25 12:50:04

etc
Developer
Registered: 2010-11-11
Posts: 4,331
Website GitHub

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

#39 2012-08-25 18:49:25

Gocom
Plugin Author
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

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

#40 2012-08-25 18:59:40

Gocom
Plugin Author
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: rah_repeat // Split and repeat.

Rah_repeat version v0.8.1 is out. Fixes the range issue.

More info and downloads

Offline

#41 2012-10-16 18:54:42

photonomad
Member
Registered: 2005-09-10
Posts: 289
Website

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

#42 2012-10-16 20:37:04

etc
Developer
Registered: 2010-11-11
Posts: 4,331
Website GitHub

Re: rah_repeat // Split and repeat.

Maybe it will be easier to sort listings by SUBSTRING_INDEX in <txp:article_custom />?

Offline

#43 2012-10-16 20:47:21

photonomad
Member
Registered: 2005-09-10
Posts: 289
Website

Re: rah_repeat // Split and repeat.

Thanks for the suggestion, etc. I’m going to have to study up on SUBSTRING_INDEX.

Offline

#44 2013-04-23 09:28:23

Gocom
Plugin Author
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

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 the rah_repeat_value tag.
  • Now requires Textpattern 4.5.0 or newer.

More info and downloads

Offline

#45 2016-04-13 19:37:58

lazlo
Member
Registered: 2004-02-24
Posts: 105

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

#46 2016-04-14 03:20:12

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,214
Website

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: 105

Re: rah_repeat // Split and repeat.

mrdale wrote #298605:

Jukka gone.

Gone, daddy… gone.

Oh, does that mean rah plugins are orphaned?

Offline

#48 2016-04-14 16:05:42

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,153
Website

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

Board footer

Powered by FluxBB