We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28215
    • 4,149 Posts
    This is an auto-generated topic for If 1.1-pl by splittingred.

    Brief Description:

    A simple conditional snippet. Allows for eq/neq/lt/gt/etc logic within templates, resources, chunks, etc.
    New in 1.1

    • Added inarray operator
    See official documentation here:http://docs.modxcms.com/display/ADDON/If
      shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
      • 1331
      • 129 Posts
      Is it possible to use more than just the two conditions? I’d like to have a few ’or’ conditions before the else statement.
        • 14822
        • 61 Posts
        bump!
          • 7557
          • 61 Posts
          Quote from: abelafonte at Aug 19, 2010, 04:04 PM

          Is it possible to use more than just the two conditions? I’d like to have a few ’or’ conditions before the else statement.
          Try ifEval snippet
          http://modxcms.com/forums/index.php/topic,55363.0.html
            • 22446
            • 181 Posts
            I am looking to us the IF snippet. What I am trying to do is check to see if a user group or role is logged in. If so I would like it to output a chunk. If not return nothing.

            This is what I have so far. It’s not working, any help would be appreciated.

            [[!If? &subject=`[[+modx.user.role]]` &operator=`==` &operand=`Members` &then=`[[$right_col_members]]` &else=``]]
              • 25287
              • 81 Posts
              I’m fairly new to Revolution, having previously built a couple of sites in Evolution. I have a small site online which I copied on my localhost. Before importing the db I set up a number of snippets. Then decided IF would be helpful so tried to install it using the latest package (downloaded yesterday). I get the following:

              Package found...now preparing to install.
              Target directory is either not a directory or writable: /core/packages/
              Could not transfer package if-1.1-pl.transport.zip to /core/packages/.
              Could not install package with signature: if-1.1-pl

              This is my second attempt - the first time the directory showed up as the online environment ie. hsphere/myname/mywebsite/core/packages/

              I went looking in phpmyadmin and discovered that path in the workspaces table and editied to /core/packages/ - still no joy.

              No other packages will install either. The question is: what is the correct Default MODx workspace on a localhost? - the path is c:/xampplite/modx/

              I’m using Rev 2.0.4-pl2 on Xampp Lite 1.7.2, Apache 2.2.12 Mysql 5.1.37 all running on a Windows 7 64-bit machine

              Thanks for any help.

              Rob
                • 22303 MODX Staff
                • 10,725 Posts
                The path needs to be an absolute filesystem path, i.e. c:/xampplite/modx/core/packages/ -- and don’t forget the trailing slash.
                  • 25287
                  • 81 Posts
                  Thanks Jason,
                  I knew it would be simple! Trying to solve issues at 3am never works too well. grin

                  Rob
                    • 25287
                    • 81 Posts
                    I’m wondering if it is possible to nest IF statements? Am wanting to test for two TV’s, with the second conditional on the result of the first test.
                    The TV "Edition" has "Open" as one of three choices, TV "format" has two options standard or panorama. I would run this three times for each possible tv.Edition

                    The code I’ve tried is:
                    [[!If? &subject=`[[*tv.Edition]]` &operator=`EQ` &operand=`Open` &then=`[[!If? &subject=`[[*tv.format]]` &operator=`EQ` &operand=`panorama` &then=[[$OpenPano]] &else=`[[$OpenEd]]` ]]`]]

                    All I get is a blank.

                    If this is not possible with IF what snippet would do this?

                    Thanks
                      • 22303 MODX Staff
                      • 10,725 Posts
                      What is tv.? Are you naming all of your TV’s with tv. at the beginning?