We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Great replacement for PHx

    Params:

    is - processed condition (that compare: how to compare: to compare with)
    then - @tpl:chunkname, or any html-code tags MODX
    else - @ tpl:chunkname, or any html-code tags MODX
    math - consist of a mathematical function in the parameter is
    separator - Separator condition in params is

    To the parser did not handle option and then and else, as it is in PHx, call: &then=`@TPL:chunkname` - where chunkname - chunk name, then it will be executed only the desired chunk.

    The operators used in the condition

    is - equal
    not - not equal
    >,gt - more
    lt - less than
    gte - greater than or equal
    lte - less than or equal
    isempty, empty - check void
    not_empty,!empty - check zapolennost
    null, is_null - check whether a variable is NULL
    in_array, inarray, in - in the presence of an array
    not_in,!in - the lack of an array

    Doing the math functions:
    &is=`[+id+]*10:=:30` &math=`on`


    examples of use
    1) Per share only need a directory with ID = 5
    [[if? &is=`[*parent*]:=:5` &then=`@TPL:akcia`]]


    2) Per share only need a directory with ID = 5 or catalog pattern № 7,8,9
    [[if? &is=`[*parent*]:is:5:or:[*template*]:in:7,8,9` &then=`@TPL: akcia`]]


    3) Per share only need a directory with ID = 5 and only the resource with the pattern number 2
    [[if? &is=`[*parent*]:=:5:and:[*template*]:is:2` &then=`@TPL: akcia`]]


    4) Per share only need a directory with ID = 5 and only the resource with the pattern number 2 or in other templates but with TV show_akcia = 1
    [[if? &is=`[*parent*]:is:5:and:[*template*]:is:2:or:[*show_akcia*]:is:1` &then=`@TPL:akcia`]]


    5) Per share only for products with a price in the range of > $ 300 < $ 700
    [[if? &is=`[*price*]:>:300:and:[*price*]:<:700` &then=`@TPL:chankname`]]


    6) the entries in the multiplicity Ditto 3
    [[if? &is=`[+ditto_itteration+]:%:3` &then=`true` &else=`false`]]


    7) Output in the multiplicity of records Ditto 3 but by multiplying the
    [[if? &is=`[+ditto_iteration+]*2:%:3` &then=`true` &else=`false` &math=`on`]]


    8) to print the value of the mathematical expression
    [[if? &is=`[+ditto_iteration+]*2` &math=`on`]]


    Source code
    https://gumroad.com/l/TAqQ

    [ed. note: dmi3y last edited this post 11 years, 4 months ago.]
      http://modx.im - Russian community
      http://extras.evolution-cms.com - Repository for Evolution
      • 13226
      • 953 Posts
      I am new to "IF" and would like to use it instead of "PHX" for well known reasons.

      Looking at the info provided I thought I would be able to get this working, but sadly, my attempt(s) haven't worked as expected.

      I am currently trying to set a chunk for a set of ID's, when I pre-define one or two it works, but more it doesn't e.g

      With two (this works):
      [[if? &is=`[*id*]:is:1:or:[*id*]:is:2` &then=`` &else=`{{chunkname}}`]]

      With multiple (doesn't work):
      [[if? &is=`[*id*]:is:1:or:[*id*]:is:2:or:[*id*]:is:3:or:[*id*]:is:4` &then=`` &else=`{{chunkname}}`]]


      Any help is welcome and appreciated.
      • correct:
        [[if? &is=`[*id*]:in:1,2,3,4` &then=`` &else=`@TPL:chunkname`]]
          http://modx.im - Russian community
          http://extras.evolution-cms.com - Repository for Evolution
          • 13226
          • 953 Posts
          Quote from: dmi3y at Nov 04, 2013, 12:05 PM
          correct:
          [[if? &is=`[*id*]:in:1,2,3,4` &then=`` &else=`@TPL:chunkname`]]

          Now thats what I call a speedy reply with an exact solution.

          Thanks dmi3y, works a treat
            • 9995
            • 1,613 Posts
            Is this possible?:

            if user / usergroup is logged in then x else y?
              Evolution user, I like the back-end speed and simplicity smiley
              • 2762
              • 1,198 Posts
              This is my first time with if snippets.

              I am currently trying to use Ditto pagination + If snippet to create a rel="prev" / "next" to avoid duplicated contents with paginate.

              My idea: Use ditto placeholder to output links

              1) removed [+prev+] [+next] placeholder from my ditto pagination (left only [+pages+])
              2) created two chunk for tplPaginatePrevious and tplPaginateNext with only [+url+]

              3) added to the head of my template

              <title>[*pagetitle*] - pag. [+currentPage+]`]] </title>
              
              <link rel="prev" href="[+prev+]" />
              <link rel="next" href="[+next+]" />


              everything works as expected smiley

              Now i need to remove the first line (<link rel="prev" href="[+prev+]" />) only in the first page
              and the second line only in the last paginated page.

              When ditto paginateAlwaysShowLinks is=0 we dont have next and previous links

              So I'm trying

              [[if? &is=`[+prev+]:is:empty` &then=`` &else=`<link rel="prev" href="[+prev+]" />`]]
              [[if? &is=`[+next+]:is:empty` &then=`` &else=`<link rel="next" href="[+next+]" />`]]


              But does not work

              Any Help?


                Free MODx Graphic resources and Templates www.tattoocms.it
                -----------------------------------------------------

                MODx IT  www.modx.it
                -----------------------------------------------------

                bubuna.com - Web & Multimedia Design
                • 2762
                • 1,198 Posts
                Any suggestion?
                  Free MODx Graphic resources and Templates www.tattoocms.it
                  -----------------------------------------------------

                  MODx IT  www.modx.it
                  -----------------------------------------------------

                  bubuna.com - Web & Multimedia Design
                  • 9995
                  • 1,613 Posts
                  Dunno if this is any help;

                  Canonical urls
                  https://support.google.com/webmasters/answer/139066?hl=en&ref_topic=2371375

                  Magento and prolly WP have plugins / extentions for that.
                    Evolution user, I like the back-end speed and simplicity smiley
                    • 9995
                    • 1,613 Posts
                    [*background:is=``:then=`/img/noimage.jpg`:else=`[[phpthumb? &input=`[*background*]` &options=`w=1600,q=90`]]`*]


                    Is this possible with IF?

                    When I try this it doesn't work, it doesn't show [*background*]

                    [[if? &is=`[*background*]` &then=`/img/noimage.jpg` &else=`[[phpthumb? &input=`[*background*]` &options=`w=1600,q=90`]]`]]
                      Evolution user, I like the back-end speed and simplicity smiley
                      • 2762
                      • 1,198 Posts
                      Quote from: fourroses666 at Feb 24, 2014, 10:08 AM
                      Dunno if this is any help;

                      Canonical urls
                      https://support.google.com/webmasters/answer/139066?hl=en&ref_topic=2371375

                      Magento and prolly WP have plugins / extentions for that.

                      Thanks, but the suggested solution for pagination issue is using rel="next" and rel="prev"

                      https://support.google.com/webmasters/answer/1663744?hl=en&ref_topic=2371375

                      In addition, i'm trying to avoid the duplicated title on pagination with this:

                      <title>[*pagetitle*] [[if? &is=`[+currentPage+]:>:1` &then=`- pag. [+currentPage+]`]] </title>


                      but does not work sad
                        Free MODx Graphic resources and Templates www.tattoocms.it
                        -----------------------------------------------------

                        MODx IT  www.modx.it
                        -----------------------------------------------------

                        bubuna.com - Web & Multimedia Design