We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17403 ☆ A M B ☆
    • 183 Posts
    Generic output filter to retrieve the first non empty value from a list.

    CODE:
    <?php
    /* shift snippet
     * phx like array_shift-array_filter output filter
    **/
    $arr    = explode("#", $options);
    $arr[]  = $input;
    return array_shift(array_filter($arr));


    USAGE: For example we have a chunk for displaying search result like below..
    <h2><a href="[[~id]]">[[+pagetitle :shift=`[[+longtitle]]#[[+menutitle]]` ]]</a></h2>
    <summary>[[%nosummary:shift=`[[+introtext]]#[[+content:striptags:elipsis=`120`]]` ]]</summary>
    Explanation from the example above:

    • H2: longtitle is the first priority, menutitle the second priority, and pagetitle became a default value
    • SUMMARY: introtext is the first priority, content (striped+elipsised) the second, and %nosummary (lexicon entry) become default value


      zaenal.lokamaya