#1 2014-07-11 05:58:20

elmigo
Member
Registered: 2014-06-17
Posts: 7

[solved] dynamic attributes?

Hello, All

I want to make watching the article
near lay block random articles of which exclude current article

this not worked template

<ion:page:article>
	<?php $tmp_id = '<ion:get key="id_article" />'; ?>
        .....	
</ion:page:article>

<h2 class="bhead slashed">Last news</h2>			
<ul class="news_list">
<ion:page:articles id="news" filter="article.id_article !=<?php print $tmp_id; ?>" limit="3" order_by="date DESC">
	<ion:article>
		<li><p><a href="<ion:url />"><ion:title /></a> <ion:content paragraph="1" /></p></li>
	</ion:article>
</ion:page:articles>						
</ul>		

how to?

Last edited by elmigo (2014-07-20 12:01:59)

Offline

#2 2014-07-11 17:43:38

elmigo
Member
Registered: 2014-06-17
Posts: 7

Re: [solved] dynamic attributes?

[solved]

solution

template:

<ion:page:article>
	<ion:get key="id_article" to_var="tmpid" />
        .....	
</ion:page:article>

<h2 class="bhead slashed">Last news</h2>			
<ul class="news_list">
<ion:page:articles id="news" filter="article.id_article!=__tmpid__" limit="3" order_by="date DESC">
	<ion:article>
		<li><p><a href="<ion:url />"><ion:title /></a> <ion:content paragraph="1" /></p></li>
	</ion:article>
</ion:page:articles>						
</ul>		

in file application\libraries\Tagmanager.php

public static function tag_get(FTL_Binding $tag)
{
	$key = $tag->getAttribute('key');

	// Value set through <ion:set ../>
	$value = $tag->get($key, 'global');

	// Try to get the Extend Field value
	if (is_null($value))
	{
		...
	}

	// If value is array then need an item or tag expand
	if(is_array($value))
	{
		...
	}
	// -------- my code: start ---------------
	else if ($to_var = $tag->getAttribute('to_var'))
	{
		$tag->set($to_var, $value, 'global');
		return;
	}
	// -------- my code: end ---------------

	return self::output_value($tag, $value);
}

in function application\libraries\Tagmanager\Article.php::get_articles
replace

	if( ! is_null($filter) )
		$filter = self::process_filter($filter);

with

	if( ! is_null($filter) )
	{
		$filter = self::process_filter($filter);
		if (preg_match('/__(.*)__/', $filter, $m))
		{
			$flt_val = $tag->get($m[1], 'global');
			$filter = str_replace("__$m[1]__", $flt_val, $filter);
		}	
	}

all of needed to me now, more vars in filter - your task

Offline

#3 2014-07-20 02:06:32

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

Re: [solved] dynamic attributes?

very interesting !


Inspiration & Innovation : Websites by Partikule, Agence Web Paris

Offline

#4 2014-07-28 14:13:40

Kink
Ion Tester
From: France
Registered: 2010-06-04
Posts: 581

Re: [solved] dynamic attributes?

Yes, i think it's a good way, in fact, the goal is to return to the fundment of Ionize : no php tags, because most of them can conflict with ionize tags.


Webmaster / OUF!WEB

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