Fork me on GitHub

Smarty + Templates + Arrays  Bottom

  • I am attempting to work on a module, using Smarty, inside a template, and with arrays.

    Here are things I need to do:

    1) Create an array variable INSIDE the template. Or I could use assign_by_ref from API file and make it available to template. In either case I must be able to MODIFY array once inside template.

    2) Must be able to remove all elements (clear) from the array. Anyone know how to do this? Sample code?

    3) Must be able to add an element (append) to the array. Anyone know how to do this? Sample code?


    Help would be much appricated. Worried what little hair I had left has just abandoned me after fighting with Smarty + Templates + Arrays for a couple of hours...

    Thanks,

    JLS
  • This, to me, doesn't sound like something you should be doing inside a template. Data should be processed in PHP and displayed in the template. The only logic in a template should be displayed based logic.

    That I know of, for the reason i've outlined, I don't believe that Smarty has array modification facilities. However Smarty is an extensible system so you can write your own plugins to solve the problems.

    I'd give some serious thought as to your current architecture. Also take a look at the Smarty documentation and forums for some additional thoughts and advice.

    -Mark

    --
    Visit My homepage and Zikula themes.
  • Fair enough. Have been looking @ documentation, that’s why I since I couldn't find much in the area of array editing/handling in the docs or forums I figured I'd ask.

    Starting to come to better understanding of where Smarty lies in the whole scheme of things.

    Will try backing the algorithm back into the userapi.php file and see if building the arrays makes better sense there.

    Thanks for the assistance,

    JLS
  • 0 users

This list is based on users active over the last 60 minutes.