I’m Making plug-in where i need to get the value of a parameter and add to an array.
I’m in the early stages but eventually the user will be able to select their favorite animals and breed and add it to a list.
I basically need to POST the selected values and put them into the array, but not using a POST and passing the value through this plug-in.
the tags on a page might look like this. there could be many to add
{exp:animals:additem arrayname="dogs" value="Labs"}
{exp:animals:additem arrayname="dogs" value="Rhodie"}
{exp:animals:additem arrayname="dogs" value="Mastiff"}
{exp:animals:additem arrayname="dogs" value="Pug"}Right now it is only inserting the last tag value “Pug” and “mydog” which is the initial value of the array.
here is section code. any suggestions?
Thanks
<pre><code>// Fetch params
$items[] = $this->EE->TMPL->fetch_param('value');
$arrayname = $this->EE->TMPL->fetch_param('arrayname');
// create an array
$_SESSION[$arrayname]= array('mydog');
//Push the items into the array
foreach($items as $value){
array_push($_SESSION[$arrayname], $value);
}</code></pre>
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.