Re: [Tiki-devel] ternary operator in smarty
Guillaume Leclerc <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.devel |
|---|---|
| Message-ID | <[email protected]> |
ah nice. thanks a lot! —— Guillaume Leclerc sleeplessmind.com.mo +853 6239 0630 On 1 April 2021 at 23:54:12, Jonny Bradley via TikiWiki-devel ([email protected]) wrote: 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 _______________________________________________ TikiWiki-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel