Textpattern CMS support forum

You are not logged in. Register | Login | Help

#61 2012-07-25 18:06:47

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

Re: rah_function // Every PHP function is a tag

THE BLUE DRAGON wrote:

Can you please provide an example of how I can get only value #3, or only value #3,#5,#6,#11.
I mean what’s the syntax of your plugin replacement-tags such as the regular <txp:rah_repeat_value /> please?

The tag <txp:rah_repeat_value /> outputs the current value split from string specified in value attribute. The tag doesn’t act as replacement tag that can get values other than the current. Rah_repeat doesn’t have replacement tag syntax as smd_each has them.

In v0.7 and older, the plugin concentrates solely on simple looping (aka iteration, repeating). The one and only way to access data is to iterate over it. Extracting parts of a string isn’t possible so to speak. The only thing you can dot to get an individual value other than the current, is to nest rah_repeat tags, iterate and use offset and limit. Please take a look at the Taking advantage of offset and limit and Repeat inside repeat examples in the help file. Both of those example can be used together. Merging those snippets gives you something along the lines of:

<txp:rah_repeat value="..." delimiter="~||~">
	Value1: <txp:rah_repeat
		value='<txp:rah_repeat_value />'
		delimiter="~|~"
		offset="0"
		limit="1"
	><txp:rah_repeat_value /></txp:rah_repeat>

	Value2: <txp:rah_repeat
		value='<txp:rah_repeat_value />'
		delimiter="~|~"
		offset="1"
		limit="1"
	><txp:rah_repeat_value /></txp:rah_repeat>

	Value3: <txp:rah_repeat
		value='<txp:rah_repeat_value />'
		delimiter="~|~"
		offset="2"
		limit="1"
	><txp:rah_repeat_value /></txp:rah_repeat>
</txp:rah_repeat>

Last edited by Gocom (2012-07-25 18:10:15)

Offline

#62 2012-07-25 18:23:25

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 562
Website

Re: rah_function // Every PHP function is a tag

Gocom wrote:

The only thing you can dot to get an individual value other than the current, is to nest rah_repeat tags, iterate and use offset and limit.

Thanks working great :)

Offline

#63 2012-09-23 21:52:13

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: rah_function // Every PHP function is a tag

Hi Jukka.
Not sure what I’m doing wrong here.
With rah_function v0.6, I’m trying this:

<txp:rah_function call="parse_url" url="http://www.example.com/test/abc" _intcomponent="PHP_URL_PATH" />

I get just http in the output

While this equivalent:

<txp:php>
  echo parse_url("http://www.example.com/test/abc", PHP_URL_PATH);
</txp:php>

correctly outputs /test/abc.

I’ve skimmed over plugin help docs, but couldn’t find a clue. Enlighten me. Thanks. :)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#64 2012-09-24 03:18:46

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

Re: rah_function // Every PHP function is a tag

PHP_URL_PATH is a constant. In the PHP snippet you are using it as such, but in the tag markup it’s considered as a string. In other words, you are passing a literal string of PHP_URL_PATH to the the function instead of the constant’s value. When converted to an integer by the _int prefix, it is passed on as a 0.

Instead of the string and constants name, you could use the constant’s returned value. Which for PHP_URL_PATH is 5. E.g.

<txp:rah_function
	call="parse_url"
	url="http://www.example.com/test/abc"
	component="5"
/>

Adding constant support could be beneficial indeed. So, commit 47d05e3 introduces a _constant prefix and makes using an constant as an attribute possible:

<txp:rah_function _constantAttr="I_LIKE_CHEESE" />

Last edited by Gocom (2012-09-24 03:32:50)

Offline

#65 2012-09-24 04:23:43

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: rah_function // Every PHP function is a tag

PHP docs on parse_url don’t show the returned values for constants. I may have figured it out if docs would have show them :)
Thanks, Jukka.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#66 2013-04-25 09:35:49

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

Re: rah_function // Every PHP function is a tag

v0.7.0 released. Changes:

  • Added: _constant attribute prefix.
  • Added: _assign attribute.
  • Changed to semantic versioning.
  • Released as a composer package.

More info and downloads

Offline

Board footer

Powered by FluxBB