#1 2014-04-15 21:36:37

MartinK
Member
From: Tallinn
Registered: 2012-03-04
Posts: 42
Website

[SOLVED] "paragraph" attribute returns unexpected output

I don't actually know if it's a bug or a feature, but currently if I specify "paragraph" tag I get all the paragraphs that are before the one specified.

Example:

<!-- Returns all first three paragraphs, not only the 3rd one -->
<ion:content paragraph="3" />

According to the specs it should return only the 3rd paragraph.

So in order to accomplish the goal, I made a little improvement in the Tagmanager.php file (lines 3452 and 3453) and replaced the tag_limiter function in MY_text_helper.php file.

Tagmanager.php:

if ( ! is_null($paragraph))
{
	$paragraphs = explode(',', $paragraph);
	if ( count($paragraphs) > 1 )
	{
		$value = tag_limiter($value, 'p', intval($paragraphs[1]), intval($paragraphs[0])-1);
	}
	else
	{
		$value = tag_limiter($value, 'p', intval($paragraphs[0]), intval($paragraphs[0])-1);
	}
}

MY_text_helper.php:

function tag_limiter($string, $tag, $nb=1, $start=0)
{
	$rString = '';
	preg_match_all('/<'.$tag.'>(.*?)<\/'.$tag.'>/s', $string, $matches);
	if (!empty($matches))
	{
		for ($i = $start; $i < $nb; $i++)
		{
			$rString.=@$matches[0][$i];
		}
	}
	return $rString;
}

after that I can do:

<!-- returns paragraphs from 2 to 5 -->
<ion:content paragraph="2,5" />

and

<!-- returns only paragraph 4 -->
<ion:content paragraph="4" />

Last edited by MartinK (2014-04-15 21:41:06)


Ionize will rule the Internet one day!

Offline

#2 2014-04-16 14:30:27

ukyo
Community Manager
From: Marmaris - Turkey
Registered: 2010-05-19
Posts: 734
Website

Re: [SOLVED] "paragraph" attribute returns unexpected output

You can use helpers with ion tags.

Example usage for text_helper -> tag_limiter

<ion:content helper="text:tag_limiter:p,2" />

<ion:ukyo from="Turkey" />
Ionize CMS Türkçe Dil Çeviri Dosyaları | My Github Repositories
Please send your first message to a forum section, not forum users or administration.

Offline

#3 2014-04-17 11:05:37

Michel-Ange
Ionize Core Team
From: Paris, France
Registered: 2010-03-22
Posts: 927
Website

Re: [SOLVED] "paragraph" attribute returns unexpected output

@MartinK : No, according to the doc, paragraph="3" will return you the third first paragraph.

http://doc.ionizecms.com/en/tags-refere … attributes

"paragraph : Limits the data to the given number of paragraphs"


Inspiration & Innovation : Websites by Partikule, Agence Web Paris

Offline

#4 2016-05-30 14:35:46

dh-webservice.eu
Member
From: Merano, Italy
Registered: 2015-10-14
Posts: 51
Website

Re: [SOLVED] "paragraph" attribute returns unexpected output

In my most recent work i tested the paragraph attribute, using Ionize 1.0.8.

For example:
<ion:content paragraph="3" />

It definitely means the following:
Put out the paragraphs no. 1 + 2 + 3 ... and not only paragraph no. 3


Ionize Fan from Northern Italy ;-)

Offline

What's Ionize ?

Ionize is an Open Source Content Management System created by webdesigners for webdesigners.

Created and maintained by Partikule and Toopixel, Ionize wants to be the easiest and most powerful CMS.

Can I help ?

Because talent is nothing without involvement, we are looking for motivated coders and webdesigners to join the project team.

Resources

Website : ionizecms.com
Documentation : doc.ionizecms.com

Development : Ionize on GitHub
Translations : Ionize Translations