Re: [Tiki-devel] ternary operator in smarty
Jonny Bradley via TikiWiki-devel <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Guill (replying on the dev list as it's a good question, share and enjoy!)
You need to join the two "else" vars together somehow, and if they're strings (usually/always?) you can use the cat modifier 😺
e.g.
{($paintiffIsIndividual) ? '**CONFIDENTIAL**' : $row['some_field']|cat:$row['some_otherfield']}
You also might be able to do it with the backtick operator:
{($paintiffIsIndividual) ? '**CONFIDENTIAL**' : `$row['some_field'] $row['some_otherfield']`}
HTH
jb
* https://www.smarty.net/docs/en/language.modifier.cat.tpl
* https://www.smarty.net/docsv2/en/language.syntax.quotes.tpl
> On 1 Apr 2021, at 15:54, Guillaume Leclerc wrote:
>
> Jonny!
>
> quick question. i was unable to use two variables next to each other with the ternary operator in smarty. is it possible or am i missing something? got confused with all the parentheses.
>
> like this works: {($paintiffIsIndividual == true) ? '**CONFIDENTIAL** : $row['some_field'']}
>
> but this doesn't: {($paintiffIsIndividual == true) ? '**CONFIDENTIAL** : ($row['some_field'] $row['some_otherfield'])}
>
> any idea? try to embrace the stuff within parentheses everywhere but would still explode.
>
> thanks!
>
_______________________________________________
TikiWiki-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel