Re: PHP smarty and subarrays

From: Date: Wed, 07 Sep 2022 07:11:19 +0000
Subject: Re: PHP smarty and subarrays
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-328056@lists.php.net to get a copy of this message
On 7 September 2022 07:38:07 BST, Andrey Repin <anrdaemon@yandex.ru> wrote: >Greetings, Ashley Sheridan. >In reply to Your message dated Monday, September 5, 2022, 14:05:09, > > >> On 05/09/2022 08:55, gordonisnz@gmail.com wrote: >>> Hi >>> >>> 1) Does anyone know of a good PHP Smarty forum? There was one, but >>> they took it off & went to Reddit - Gone downhill since then (very few >>> people transferred) >>> >>> or can i ask my smarty questions here? (not many folks may use smarty ??) >>> >>> 2) Question:- >>> >>> I know how to assign values within a template: >>> >>> {if !isset($HIDEMAINMENU)}{assign var="HIDEMAINMENU" >>> value="0"}{/if} >>> >>> however, does anyone know the correct way of assigning (or retrieving) >>> sub-arrays? >>> >>> (PHP) >>> $myarray["animals"]["movies"]["settings"]["trees"] = 5; >>> >>> How do I set it to do the same thing with smarty:- the only examples >>> i can see, assign NEW arrays (not assigning new keys/values to an >>> existing array) >>> >>> Or >>> >>> How to assign a sub-array value to a $temp variable (not an array) >>> >>> When I try the obvious things - i get all sorts of errors >>> >>> -- >>> >>> Gordon. > >> From looking at the docs, it would seem you can use any valid PHP within >> the templates using {php}...{/php} : >> https://www.smarty.net/docsv2/en/language.function.php.tpl > >Why are you linking to v2 docs? >{php}{/php} tags were deprecated for over a decade. > >> This means you could set what you wish and use those variables within the >> Smarty templates using the normal Smarty syntax if you wish (as it all translates into PHP >> commands anyway) > > Just the first result in a Google search. I'm not a Smarty dev. The leap to a current solution isn't too far, following this.

« previous php.general (#328056) next »