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

    I have been wondering how to use the new Evo modifiers and it was suggested in Evo GitHub to post this in the forums.

    It appears that there are a number of different ways to write the new modifier calls but what I like the best is the "like for like replacement" with a PHx minimal call - eg
    [*submenu:is=`no`:then=``:else=`{{sub-menu}}`*]


    Just wondering if users that are good with the new Evo modifiers could please check #5 below and confirm the equivalent call for the new modifiers.

    I will update this post and then perhaps we have a good starting point for a comparison that could eventually be added to the new Evo docs.

    Please reply with any other handy PHx / IF / Modifiers Comparisons.

    Thanks so much.


    1 scenario: If a TV named submenu equals the word no then show nothing, otherwise display a chunk {{sub-menu}}
    usage: if / then / else direct in a template

    PHx long
    [+phx:if=`[*submenu*]`:is=`no`:then=``:else=`{{sub-menu}}`+]


    PHx minimal
    [*submenu:is=`no`:then=``:else=`{{sub-menu}}`*]


    IF
    [[if? &is=`[*submenu*]:is:no` &then=`` &else=`{{sub-menu}}`]]


    New Modifiers (same as PHx minimal)
    [*submenu:is=`no`:then=``:else=`{{sub-menu}}`*]



    2 scenario: If a TV named submenu equals the word yes then show a chunk {{sub-menu}}
    usage: if / then direct in a template

    PHx long
    [+phx:if=`[*submenu*]`:is=`yes`:then=`{{sub-menu}}`+]


    PHx minimal
    [*submenu:is=`yes`:then=`{{sub-menu}}`*]


    IF
    [[if? &is=`[*submenu*]:is:yes` &then=`{{sub-menu}}`]]


    New Modifiers (same as PHx minimal)
    [*submenu:is=`yes`:then=`{{sub-menu}}`*]



    3 scenario: If the longtitle field is empty, display pagetitle - sitname, otherwise display longtitle - sitename
    usage: if / then / else direct in a template

    PHx long
    [+phx:if=`[*longtitle*]`:is=``:then=`[*pagetitle*] - [(site_name)]`:else=`[*longtitle*] - [(site_name)]`+]


    PHx minimal
    [*longtitle:is=``:then=`[*pagetitle*] - [(site_name)]`:else=`[*longtitle*] - [(site_name)]`*]


    IF
    [[if? &is=`[*longtitle*]:empty` &then=`[*pagetitle*] - [(site_name)]` &else=`[*longtitle*] - [(site_name)]`]]


    New Modifiers (same as PHx minimal)
    [*longtitle:is=``:then=`[*pagetitle*] - [(site_name)]`:else=`[*longtitle*] - [(site_name)]`*]


    New Modifiers using "ifempty"
    [*longtitle:ifempty:then`[*pagetitle*] - [(site_name)]`:else`[*longtitle*] - [(site_name)]`*]



    4 scenario: If the description field is not empty, display the meta description
    usage: if / then direct in a template

    PHx long
    [+phx:if=`[*description*]`:isnot=``:then=`<meta name="description" content="[*description*]">`+]


    PHx minimal
    [*description:isnot=``:then=`<meta name="description" content="[*description*]">`*]


    IF
    [[if? &is=`[*description*]:!empty` &then=`<meta name="description" content="[*description*]">`]]


    New Modifiers (same as PHx minimal)
    [*description:isnot=``:then=`<meta name="description" content="[*description*]">`*]


    New Modifiers with different method
    [*description:is=``:then=``:else=`<meta name="description" content="[*description*]">`*]



    5 scenario: Display 50 words from the content field
    usage: in a ditto row template

    PHx minimal
    [+content:word_limit=`50`+]
    
    with a snippet called "phx:word_limit"
    
    <?php
    $retval = $output;
    $array = explode(" ", $output);
    if (count($array)<=$options)
     {
      $retval = $output;
     }
     else
     {
      array_splice($array,$options);
      $retval = implode(" ", $array);
     }
    return $retval;
    ?>


    New Modifiers huh
    Can this be achieved with the new modifiers?
    [ed. note: nickf08 last edited this post 7 years, 1 month ago.]
      Web design Adelaide
      http://gocreate.com.au