<![CDATA[ How to use multiple id's and then statements with else - My Forums]]> https://forums.modx.com/thread/?thread=104849 <![CDATA[How to use multiple id's and then statements with else]]> https://forums.modx.com/thread/104849/how-to-use-multiple-id-s-and-then-statements-with-else#dis-post-563795
I'm having a difficult time finding the right info I'm looking for and I feel I'm so close. So, essentially I need to have a footer display the proper chat window depending on what page the viewer is on. I *could* do all this making unique templates for each and every chat I need and just add the chat window stuff in, but I feel thats the improper way of coding.

The code I have thus far is

[[*id:is=`43`:then=`This will display Code A`:or:id:is=`9`:then=`This will display CODE B`:else=`[[$pc-hhl]]`]]

The code logic looks fine to me, so I'm unsure of where I'm going wrong.

Admittedly I am a jr dev who has switched to IT so my coding skills are getting a bit relaxed. Thank you in advance

]]>
brittislove Jan 28, 2019, 04:48 PM https://forums.modx.com/thread/104849/how-to-use-multiple-id-s-and-then-statements-with-else#dis-post-563795
<![CDATA[Re: How to use multiple id's and then statements with else]]> https://forums.modx.com/thread/104849/how-to-use-multiple-id-s-and-then-statements-with-else#dis-post-563797
Thank you]]>
brittislove Jan 28, 2019, 10:13 PM https://forums.modx.com/thread/104849/how-to-use-multiple-id-s-and-then-statements-with-else#dis-post-563797
<![CDATA[Re: How to use multiple id's and then statements with else]]> https://forums.modx.com/thread/104849/how-to-use-multiple-id-s-and-then-statements-with-else#dis-post-563796
[[*chat:notempty=`[[$ChatCodeA]]`:else=`[[$ChatCodeB]]`]]


Another method would be to create a snippet and test for resource ids, or template ids, and then output the correct chunk needed. Below detects if template id '1' or '3' is used.

if ($modx->resource->get('template') == '3' || '1') {
  $chunk = $codeAChunk;
} else {
  $chunk = $codeBChunk;
}

return $modx->getChunk($chunk);
]]>
lkfranklin Jan 28, 2019, 06:49 PM https://forums.modx.com/thread/104849/how-to-use-multiple-id-s-and-then-statements-with-else#dis-post-563796