Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#11 2009-11-29 10:58:22

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

Re: rah_repeat // Split and repeat.

the_ghost wrote:

I edited first version to add trim for exploded values.

Thank you for efforts. If someone wants to trim the string, the user can use a plugin that allows one to use trim (rah_function for example). I won’t be adding anykind of output formating in the plugin.

As we speak, it seems that 0.3 is now stable and will be feature locked, meaning that it is the final version and no new features are planned.

Offline

#12 2009-11-30 07:08:16

the_ghost
Plugin Author
From: Minsk, The Republic of Belarus
Registered: 2007-07-26
Posts: 907
Website

Re: rah_repeat // Split and repeat.

I think trimming and deleting lonely delimiters is rather useful. Imaging we create list of values and get such string: Minsk, Tokio, New-Yourk, Oslo, Helsinki, – in such way we will get 6 repeatings, instead of 5. To eliminate this we have to use if_last logic while geenrating string.

And another usful tag, just thought about it – rah_if_last/first – will be very good :)

Last edited by the_ghost (2009-11-30 07:09:26)


Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?

Offline

#13 2009-11-30 07:34:37

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

Re: rah_repeat // Split and repeat.

the_ghost wrote:

I think trimming and deleting lonely delimiters is rather useful. Imaging we create list of values and get such string: Minsk, Tokio, New-Yourk, Oslo, Helsinki, – in such way we will get 6 repeatings, instead of 5. To eliminate this we have to use if_last logic while geenrating string.

But it should be optional, and those can be done with plain TXP markup. Those aren’t required in the plugin itself. So, where optional attributes are nice, they make the plugin slower.

Still don’t get what this should do:

$delim_length = strlen($delimiter);
		if (substr($value, -$delim_length) == $delimiter) {
			$value = substr($value, 0, -$delim_length);
		}

You do know that the value will be empty after the trim and empty values can be nullified by checking if the value is empty.

Therefor we get:

<txp:rah_repeat value="foo, bar">
	<txp:rah_function call="trim">
		<txp:rah_repeat_value />
	</txp:rah_function>
</txp:rah_repeat>

Wich we can put inside <txp:variable/> and check if it exists. If it doesn’t we do none.

And another usful tag, just thought about it – rah_if_last/first – will be very good :)

Nice. rah_repeat_if_last/first are things that we might see in upcoming update. Thank you for good request.

For those that need _if_first right now, you can currenlty use offset to simulate that. And if_last is doable with if_variable.

Offline

#14 2009-11-30 07:51:00

the_ghost
Plugin Author
From: Minsk, The Republic of Belarus
Registered: 2007-07-26
Posts: 907
Website

Re: rah_repeat // Split and repeat.

A little more explanation:

$delim_length = strlen($delimiter); // get the length of delimiter (what if we set 'zzz' as delimiter? This can happen :)
		if (substr($value, -$delim_length) == $delimiter) { // cut the last 3 chars from string and check if they are delim (if delim was ',' - we would cut 1 char)
			$value = substr($value, 0, -$delim_length); // return string without last 3 chars, because they was unused delimiter
		}

That’s all.


Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?

Offline

#15 2009-11-30 08:13:53

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

Re: rah_repeat // Split and repeat.

the_ghost wrote:

A little more explanation:

Thanks, but I didn’t mean you need to explain what it does. I know what it does, but I’m wondering why it is there. You can do it with empty check. As I said:

You do know that the value will be empty after the trim and empty values can be nullified by checking if the value is empty.

Offline

#16 2009-11-30 09:19:03

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

Re: rah_repeat // Split and repeat.

Released version 0.4 of rah_repeat. Changelog:

  • Fixed: now returns old parent global, if two tags are used inside each other, instead of defining it empty.
  • Added: <txp:rah_repeat_if_first>.
  • Added: <txp:rah_repeat_if_last>.

More info and downloads

Offline

#17 2010-05-08 21:37:34

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

Re: rah_repeat // Split and repeat.

Released an update. Version 0.5 adds some new possiblities.

  • Added attribute: duplicates.
  • Added attribute: sort.
  • Offset’s default value is now zero (0) instead of unset.

From this version onwards, you can feed the tag duplicate values and it will remove them if you set duplicates attribute to 1.

The new sorting allows you to rearrange the values. For example if you feed the tag image IDs in random order, and you want them in lowest ID to highest, now it’s possible with the sort attribute.

Plugin page and downloads

Offline

#18 2010-05-09 03:20:43

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

Re: rah_repeat // Split and repeat.

Meds here, v0.6 landed shelves.

  • Added attribute: exclude. Exclude is the racist attribute, always excluding.
  • Fixed unworking <txp:rah_repeat_if_last> tag caused by v0.5 update. Duct tape!

Aids, fix and less crappy jokes

Offline

#19 2010-05-17 14:32:15

aswihart
Member
From: Pittsburgh, PA
Registered: 2006-07-22
Posts: 345
Website

Re: rah_repeat // Split and repeat.

I’m trying to use this with adi_calc, letting adi_calc dynamically change values with each repeat, so I don’t really have a use for the value attribute in rah_repeat. But, it seems I have to plug in some values in the value attribute, greater than or equal to the limit attribute, in order for it to do it’s job: repeat. Is that the intended behavior?

Offline

#20 2010-05-18 04:00:54

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

Re: rah_repeat // Split and repeat.

aswihart wrote:

Is that the intended behavior?

Yes it is.

Offline

Board footer

Powered by FluxBB