content-management-systemmodxditto

Modx Ditto display count


Can i use a variable inside Ditto placeholder? For example

[!Ditto? &tpl=`TPL-jc` &display=$myVar]

instead of

[!Ditto? &tpl=`TPL-jc` &display=`10`]

Solution

  • You can use another Element inside a Ditto placeholder, e.g.

    [!Ditto? &tpl=`TPL-jc` &display=`[+myVar+]`]
    

    (that's myVar as a placeholder)

    [!Ditto? &tpl=`TPL-jc` &display=`[myVar]`]
    

    (that's myVar as a Snippet that outputs the value you want)

    [!Ditto? &tpl=`TPL-jc` &display=`[*myVar*]`]
    

    (that's myVar as a Template Variable)