Page 1 of 1

Dynamic variable in Gallery-template?

Posted: Fri Jul 25, 2025 12:35 pm
by emgaron
In my Gallery-galleries, I am using thee custom fields "description_en", "description_de" and "description_nl" to be able to have language-specific descriptions. Now I'm trying to deal with these in the Gallery-template "automatically" (i.e. dependent on a global $lang variable).

Based on what I could find e.g. here in the forum (viewtopic.php?t=72290), I would expect something like this to work: {$fields.description_{$lang}.value} - however, when I try to use a construct like that in my Gallery-template, I'm getting an "OOOPS" with the error 'Unexpected "{", expected one of: "}"'. I'm probably missing something obvious - anyone who can point out the error in my ways? ;D

Re: Dynamic variable in Gallery-template?

Posted: Sat Jul 26, 2025 12:28 am
by DIGI3
There might be a better way, but I'd try:

Code: Select all

{$tmp="description_{$lang}"}
{$fields.$tmp.value}
(not tested)

Re: Dynamic variable in Gallery-template?

Posted: Sat Jul 26, 2025 9:27 am
by emgaron
Thank you! I think you found the one combination I had not thought off... ;) This does indeed work, which means that I can strike another step off my list. Nice!

BTW: I did try the original syntax as described in my first post in ordinary page templates and even on pages themselves, and there, this approach does work. Hence, I assume that it is actually correct Smarty-syntax, but that the way the templates are interpreted in Gallery somehow interferes with it...

Re: Dynamic variable in Gallery-template?

Posted: Sat Jul 26, 2025 3:17 pm
by DIGI3
It's possible they needed an {eval}, depends how or if the template is parsed through Smarty, or when it happens.