We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28033
    • 925 Posts
    Right now in my snippet, I have it looking for stuff like &extra=`y`.

    Is there a way to, instead of doing this, have it check if one out of a list of values exist, and use X code via a IF/ELSE statement. I don’t know much PHP, but this should give an idea...

    if (isset($width, $colspan, $rowspan)) {
    return ’<td class="’.$css.’" width="’.$width.’" colspan="’.$colspan.’" rowspan="’.$rowspan.’">’.$data.’</td>’;
    } else {
    return ’<td class="’.$css.’">’.$data.’</td>’;
    }

    (Looking at that, I’m guessing that works, then? Or does that mean it needs all three to work?)
      My Snippets
      -> PopUpChunk v1.0
      • 3749
      • 24,544 Posts
      It would be nice if that worked but you have to test them individually and use the logical AND operator (&&)

      if (isset($width) && isset($colspan) && isset($rowspan) ) {
      
      } else {
      
      }


      If any one of them is NOT set, the else will execute.



      Bob

        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
        • 7231
        • 4,205 Posts
        Or if you want it to be true if any of the variables are set change the && (AND) to || (OR) operator.

        if (isset($width) || isset($colspan) || isset($rowspan) ) {
        
        } else {
        
        }
        The else will be called if none of the variables are set.

        I like the php talk, would be nice to have a dedicated php sub forum.
          [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

          Something is happening here, but you don&#39;t know what it is.
          Do you, Mr. Jones? - [bob dylan]
          • 3749
          • 24,544 Posts
          Quote from: dev_cw at Nov 08, 2007, 05:34 AM

          I like the php talk, would be nice to have a dedicated php sub forum.

          I was just thinking the same thing. Many newcomers to MODx find that they have to learn some php to do what they want and it might be nice if the info they were looking for was all in one place and not cluttering up the other forums.

          Bob
            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
            • 7231
            • 4,205 Posts
            I was just thinking the same thing. Many newcomers to MODx find that they have to learn some php to do what they want and it might be nice if the info they were looking for was all in one place and not cluttering up the other forums.
            And it could include issues with integrating with the API, this sort of info helps everyone. I think that this would be a great resource for everyone.
              [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

              Something is happening here, but you don&#39;t know what it is.
              Do you, Mr. Jones? - [bob dylan]
              • 28033
              • 925 Posts
              So *that* is how it’s done. *makes a note*

              Thanks for the quick response.
                My Snippets
                -> PopUpChunk v1.0