Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8693287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:31:01+00:00 2026-06-13T00:31:01+00:00

I wrote a basic Smarty modifier that emulates JavaScript’s push. function smarty_modifier_push($array, $push){ if(!isset($array)){

  • 0

I wrote a basic Smarty modifier that emulates JavaScript’s push.

function smarty_modifier_push($array, $push){
    if(!isset($array)){
        $array = array($push);
    }elseif(is_array($array)){
        $array[] = $push;
    }
    return $array;
}

Here is my code in my .tpl file

Problems: 
<select name="problems[]" multiple="multiple">
    <option value="">Select Problems</option>
    {foreach from=$problems key=id item=name}
        {$newArray|push:$id}
        <option value="{$id}">{$name}</option>
    {/foreach}
</select>
{$newArray}

Problem:
My dropdown consists of about 20 elements so $newArray should have about 20 id’s in it but when I check $newArray, it is empty. So it seems that it never gets assigned back to the template after the modifier runs.

I know that I can use {assign var=newArray} in my .tpl file beforehand but I’m hoping that there is a way of assigning new variables from within a modifier function. I also know it’s possible from a function plugin because it gets passed the $smarty variable, but I just want to know specifically, How I can make this work using a modifier plugin?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T00:31:02+00:00Added an answer on June 13, 2026 at 12:31 am

    There is some code posted on the SMARTY FORUM that might help you out. Other people have pointed out that it is a way for you to do what you need but its a little complicated and is not guaranteed to work when new updates come out. Hope it helps you out though. Cheers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently wrote an extremely basic edge detection algorithm that works on an array
I wrote a streaming radio app that is fairly basic in functionality but some
I wrote this basic function : int save_files(PCHAR fileName) { errno_t err; FILE* pFile
I'm Visual Basic beginner, yesterday i wrote a dictionary that give you the opposite
I am writing modular javascript code. I wrote a basic calculator with two inputs
I wrote a basic UNIX program that uses some low-level I/O. Nothing special, here's
I wrote a basic two-view application that switches from one view to another every
I wrote a basic Hippity Hop program in C, Python, and OCaml. Granted, this
I wrote a basic python program to parse android's resources.arsc. it prints out all
I wrote a basic hello world program in haskel and tried to compile it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.