We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12958
    • 9 Posts
    Hello,
    I don`t understand the way how to control the output of chunks via snippet.
    For example: my snippet validates the input of a form and sets the value of $error = 1;
    In this case I want my Resource to display (in addition to the normal content) 2 different Chunks: $fehler and $solution.
    How and where do I have to pass the value of $error to create the desired output?

    Many thanks in advance,
    Inka
      • 3749
      • 24,544 Posts
      Quote from: Inka27 at Oct 20, 2010, 05:13 AM

      Hello,
      I don`t understand the way how to control the output of chunks via snippet.
      For example: my snippet validates the input of a form and sets the value of $error = 1;
      In this case I want my Resource to display (in addition to the normal content) 2 different Chunks: $fehler and $solution.
      How and where do I have to pass the value of $error to create the desired output?

      Many thanks in advance,
      Inka

      This might (or might not) be what you want:


      <?php
      /* Validate form here and set $form_error to true or false */
      
      $output = '';
      if ($form_error) {
      
         $output .= $modx->getChunk('fehler');
         $output .= $modx->getChunk('solution');
       }
      
      return $output;


      FWIW, I would not use $error as a variable name.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 12958
        • 9 Posts
        It´s so easy! Works fine - thank you very much!
          • 3749
          • 24,544 Posts
          Glad it worked. smiley
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting