We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 54265
    • 10 Posts
    Good morning all,

    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

      • 17301
      • 932 Posts
      Output modifers may not be the best way to get the job done. What you could do, if its likely to be on more than just a set array of resources, is to create a template variable where you could just toggle the chat code on and off. So if for example you created a TV called 'chat' you could toggle between what chunk will be displayed with the below code.


      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);
        ■ email: [email protected] | ■ website: https://alienbuild.uk

        The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
        • 54265
        • 10 Posts
        Ok thank you for the input. I went ahead and just created different templates with different footer chunks in the mean time. My idea was to have 3 different pages pull up 3 different chats.

        Thank you