No, you will need to serialize it some way. Try something like this.
{exp:mytag:subtag myparameter="<?php echo serialize($data_array); ?>"}
public function subtag()
{
$myparameter = (($myparameter = $this->EE->TMPL->fetch_param('myparameter', FALSE)) !== FALSE) ? @unserialize($myparameter) : FALSE;
if ($myparameter !== FALSE AND is_array($myparameter))
{
// should be an array
}
}tried serializing it. the array is broken. im making a plugin that preferably uses an array as input to process data.
code on template:
<?php
$myarray = array(
'rere' => 'dasdad',
'lala' => 'dsdsd'
);
?>
{exp:mytag:mymethod data_array="<?php echo serialize($myarray); ?>"}echo echoed, myarray returns
a🔢{s:4:"rere";s:6:"dasdad";s:4:"lala";s:5:"dsdsd";}
code inside the plugin:
$data_array = $this->EE->TMPL->fetch_param('data_array');
print_r ($data_array);returns a🔢{s:4:
tried using stripslashes. same thing, the array is broken. any ideas?
Here is another untested attemp:
{exp:mytag:subtag myparameter="<?php echo http_build_query($data_array); ?>"}
public function subtag()
{
$myparameter = $this->EE->TMPL->fetch_param('myparameter', FALSE);
parse_str($myparameter, $myarray);
if (is_array($myarray))
{
// should be an array
}
}If that does not work you can always take the approach of getting the data in by another means besides a parameter. Take a look at http://ellislab.com/expressionengine/user-guide/development/usage/session.html#cache
Here is another untested attemp:If that does not work you can always take the approach of getting the data in by another means besides a parameter. Take a look at http://ellislab.com/expressionengine/user-guide/development/usage/session.html#cache{exp:mytag:subtag myparameter="<?php echo http_build_query($data_array); ?>"} public function subtag() { $myparameter = $this->EE->TMPL->fetch_param('myparameter', FALSE); parse_str($myparameter, $myarray); if (is_array($myarray)) { // should be an array } }
thanks for the help, i figured it out
here goes
{exp:mytag:subtag data_array="<?php echo urlencode(serialize($data_array)); ?>" }to access it
$data_array = $this->EE->TMPL->fetch_param('data_array');
$data_array = unserialize(urldecode($data_array));it seems that the problem is on the double quotes and curly brackets. CHEERS!
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.