We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6318
    • 11 Posts
    Hi,

    In another thread, ( http://modxcms.com/forums/index.php?topic=60635 ) it’s been suggestd to me to try this snippet code to acchieve my goals.

    I have tried the snippet code on my Revolution installation. The result is that the page where I insert the snippet, when displayed, shows nothing. It is entirely blank, nothing, not even the template, and no error code.

    Here is the code:


    <?php
    /* UserGroups snippet*/
    
    /*$user = &$modx->user;
    
    if ($user->isMember('membres') {
    
         $output = $modx->getChunk('membres');*/
         $output = 'TEST A'; /*
    
    }
    
    elseif ($user->isMember('administrateurs') {
    
         $output = $modx->getChunk('administrateurs');
    
    }
    
    elseif ($user->isMember('employes') {
    
         $output = $modx->getChunk('employes');
    
    }
    
    else {
    
         $output = $modx->getChunk('offline');
    $output = 'TEST B';
    }
    
    return $output; */




    I think I have pined down the problem, wich seems to be the $output function. As I have done in the code above, everything is commented exept the $output line.

    By the way, I am not a php coder, so please don’t be too harsh!
      • 3749
      • 24,544 Posts
      You need to return something from the snippet in order for there to be any output on the page.

      Uncomment the line

      return $output;


      The original code sets the output to the content of one of the four chunks. The chunks must exist, must contain some text/HTML, and their names must be spelled the same in the snippet (case-sensitive) as their real names.

        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
        • 6318
        • 11 Posts
        Quote from: BobRay at Feb 10, 2011, 08:58 PM

        You need to return something from the snippet in order for there to be any output on the page.

        Uncomment the line

        return $output;


        The original code sets the output to the content of one of the four chunks. The chunks must exist, must contain some text/HTML, and their names must be spelled the same in the snippet (case-sensitive) as their real names.



        Thank you. I have uncommented the last line, and double checked the chunks, the names etc. Everything is written correctly.

        The result is still a totally blank page. Any hint?
          • 3749
          • 24,544 Posts
          Sorry, typos in the code -- I was typing too fast. Try this (cut and paste the code):

          <?php
          /* UserGroups snippet*/
          
          $user =& $modx->user;
          
          if ($user->isMember('membres') ) {
          
               $output = $modx->getChunk('membres');
          
          } elseif ($user->isMember('administrateurs') ) {
          
               $output = $modx->getChunk('administrateurs');
          
          } elseif ($user->isMember('employés') ) {
          
               $output = $modx->getChunk('employés');
          
          } else {
          
               $output = $modx->getChunk('offline');
          
          }
          
          return $output;
            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
            • 6318
            • 11 Posts
            Quote from: BobRay at Feb 10, 2011, 09:14 PM

            Sorry, typos in the code -- I was typing too fast. Try this (cut and paste the code):

            <?php
            /* UserGroups snippet*/
            
            $user =& $modx->user;
            
            if ($user->isMember('membres') ) {
            
                 $output = $modx->getChunk('membres');
            
            } elseif ($user->isMember('administrateurs') ) {
            
                 $output = $modx->getChunk('administrateurs');
            
            } elseif ($user->isMember('employés') ) {
            
                 $output = $modx->getChunk('employés');
            
            } else {
            
                 $output = $modx->getChunk('offline');
            
            }
            
            return $output;


            Thank you again. I have copied/pasted the code as is, then changed "employés" to "employes" in the snippet and in the chunks just to be sure that the cause would not be the accents.

            The problems still remains, I have a totally blank page.

            I appreciate your help by the way.
              • 3749
              • 24,544 Posts
              Put this as the first line of the snippet:

              return "Hello from the snippet!";


              If that doesn’t work, your snippet name probably doesn’t match the snippet name in the tag (again, case-sensitive).
                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
                • 6318
                • 11 Posts
                Quote from: BobRay at Feb 10, 2011, 09:22 PM

                Put this as the first line of the snippet:

                return "Hello from the snippet!";


                If that doesn’t work, your snippet name probably doesn’t match the snippet name in the tag (again, case-sensitive).

                I have added the line at the very beginning of the snippet, after " <?php ". I also have checked the snippet call. Everything is written correctly.

                The problem is still there, there is only a blank page.

                I have included screenshots illustrating the problem:

                Snippet call:



                Result:

                  • 3749
                  • 24,544 Posts
                  Your screenshot does not show that code at the top of the snippet. Are you sure you saved it (and cleared the site cache) after adding the line?
                    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
                    • 6318
                    • 11 Posts
                    Quote from: BobRay at Feb 10, 2011, 09:37 PM

                    Your screenshot does not show that code at the top of the snippet. Are you sure you saved it (and cleared the site cache) after adding the line?

                    I have cleared the cache, from Modx’s content, the permission cache, and my browser’s cache.

                    Here are the screenshots:

                    http://www.jordanroy.net/random/1.png

                    http://www.jordanroy.net/random/2.png

                    Thank you.
                      • 3749
                      • 24,544 Posts
                      On the right side of the screenshots, I don’t see this as the first line of your snippet:

                      return "Hello from the snippet!";
                        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