We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7557
    • 61 Posts
    This is an auto-generated topic for ifEval 0.1-pl by dj13.

    Brief Description:

    Very simple snippet for comparison operations on TV, placeholders and other values. Use the correct PHP code for input parameter, as the expression in the 'IF' function in PHP.
    First initial version.
      • 7557
      • 61 Posts
      EXAMPLES:

      In template with contentTrue and contentFalse parameter
      [[!ifEval? &input=`stripos([[*pagetitle]], "a")===0` &contentTrue=`<h3>Article with first letter A</h3>` &contentFalse=`<h3>Article with first letter different from A</h3>`]]


      In chunk without contentFalse (greater than or equal to, or less than or equal to)
      [[!ifEval? &input=`[[+price]]>=125 or [[+price]]<=175` &contentTrue=`<a href="product.html">MyProduct price:[[+price]]</a>`]] 


      In chunk 2 placholder comparasion
      <div><img src="[[!ifEval? &input=`[[+quantity]]<10 and "[[+tag]]"=="phone"` &contentTrue=`images/last10phone.jpg` &contentFalse=`images/phone.jpg`]]" alt="Product icon"/> [[+pagetitle]]</div>



        • 14822
        • 61 Posts
        Tnx a great addon but what is wrong here?

        [[!ifEval? &input=`([[+gallery.id]]===0)` &contentTrue=`[[$Rotator]]` &contentFalse=`[[$galProductos]]`]]


        Show me this error

        Parse error: syntax error, unexpected '[' in /var/www/hogarama/core/cache/elements/modsnippet/28.include.cache.php(33) : eval()'d code on line 1
          • 1778
          • 659 Posts
          Hi
          I guess you don’t need parenthesis around ([[+gallery.id]]===0) and not sure if in this case teh "===" is allowed.
          Cheers
            • 14822
            • 61 Posts
            Hi anso, tnx, "===" is allowed check the first example, but I don’t know what happend, when i used in the &input a [[+placeholder]] ve always the same error, i try with [[+placeholder]] other than [[+ gallery.item]] and the result is always the same:

            Parse error: syntax error, unexpected '[' in /var/www/hogarama/core/cache/elements/modsnippet/28.include.cache.php(33) : eval()'d code on line 1


            what is wrong?

              • 7557
              • 61 Posts
              Quote from: JoZ3 at Oct 08, 2010, 02:52 PM

              Hi anso, tnx, "===" is allowed check the first example, but I don’t know what happend, when i used in the &input a [[+placeholder]] ve always the same error, i try with [[+placeholder]] other than [[+ gallery.item]] and the result is always the same:

              Parse error: syntax error, unexpected '[' in /var/www/hogarama/core/cache/elements/modsnippet/28.include.cache.php(33) : eval()'d code on line 1


              what is wrong?


              Hi.
              There is error in first example. Quote mising around TV pagetitle. Corect code:
              [[!ifEval? &input=`stripos("[[*pagetitle]]", "a")===0` &contentTrue=`<h3>Article with first letter A</h3>` &contentFalse=`<h3>Article with first letter different from A</h3>`]]

              Anso is half-right smiley (thx). You don’t need parenthesis around ([[+gallery.id]]===0), and "===" is allowed but not need in this case.
              From PHP net: (http://php.net/manual/en/language.operators.comparison.php)
              $a == $b Equal TRUE if $a is equal to $b.
              $a === $b Identical TRUE if $a is equal to $b, and they are of the same type. (introduced in PHP 4)
              INPUT must be correct PHP expresion (or syntax). In Your case probably [[+gallery.item]] or other placholders is something difreent than number. If You want to do comparison on placholders which may be blank, empty, string, everthing different than numbers You must use quote.
              This is righ code I think (if galery with id 0 exist):
              [[!ifEval? &input=`"[[+gallery.id]]"==0` &contentTrue=`[[$Rotator]]` &contentFalse=`[[$galProductos]]`]]

              For simple comparisons may be better to use IF snippet, ifEval is intended to use with multiple comparasions and others complex operators.
                • 14822
                • 61 Posts
                Tnx a lot dj13 with "" work perfect, nice work, congratz grin
                  • 8168
                  • 1,118 Posts
                  Hi dj13 - your solution here looks like it might be able to solve my quandary also! I have started a thread here on this - http://modxcms.com/forums/index.php/topic,55671.msg320261.html#msg320261 Any chance you could have a look and let me know if something like the solution you suggest here could work for me?


                  Cheers,

                  dubbs.
                    • 3749
                    • 24,544 Posts
                    Just a note: I think the ifEval transport package has an improper signature. It should be ifEval-0.9.0-beta1. Instead, it's ifEval-0.9-beta1. This may be due to a typo in the build.transport.php file. The signature is derived from the filename of the transport file. I'm not sure what the best fix would be.
                      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