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
Watch
GitHub Core
Show your support for Zikula! Sign up at Github account and watch the Core project!
GitHub Modules
- mesteele101 responded to »ERR (3): E_USER_ERROR: Smarty error: [in pagesvar:pagesitem2en line XXX]…« 07:01 AM
- mazdev responded to »Pages 2.5.0 and updating - Page not found« 06:41 AM
- ehdwma created topic »Hide "Register new account" and change template to 3 col« 06:27 AM
- mesteele101 responded to »Zikula 1.3.3 - Selecting a category in Pages not working« 01:29 AM
- mdee created topic »How to implement returnpage ?« 01:00 AM
- nestormateo responded to »Fillters in Clip« 24. May
- damon responded to »Can the Updated Version Check be Turned Off (Z 1.3)« 24. May
Zikula Blog
- Anatomy of Open Source Projects on Mar 07
- Continuous Review on Mar 01
- Not Invented Here on Feb 24
- How to Contribute Your Code at Github on Jan 13
- 10 Steps to Coding-Nirvana: Tips for Successful Module Writing on Nov 12
- Submitting Bug Report Tickets That Get Results on Aug 17
- Cozi Tricks #1: Syntax Highlighting on Aug 07
Login
Smarty + Templates + Arrays
-
- Rank: Team Member
- Registered: Mar 18, 2002
- Last visit: Oct 21, 2009
- Posts: 6606
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. -
**unknown user**
- Rank: Registered User
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 41
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
- Moderated by:
- Support
Users on-line
- 0 users
This list is based on users active over the last 60 minutes.
