We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Plugin: Inserting values into an array

Development and Programming

kmgkid's avatar
kmgkid
50 posts
15 years ago
kmgkid's avatar kmgkid

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>
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.