We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36519
    • 40 Posts
    I was wondering what is the best practice to display double brackets combo (ie., [[snippet]] ) on modx site pages.

    I need to do this to explain how to use my custom snippets in user help page.

    I am currently using HTML codes [[snippet name ]]
    However, with this solution, I can not use rich text editor (editor will translate them to brackets at the next save so the snippet will execute)

    This question has been answered by benmarte. See the first response.

    [ed. note: masakia last edited this post 11 years, 2 months ago.]
    • discuss.answer
        Benjamin Marte
        Interactive Media Developer
        Follow Me on Twitter | Visit my site | Learn MODX
        • 36519
        • 40 Posts
        Thank you, I missed that thread.
        Since I had 12 hours (flying from Narita Japan to Detroit USA) before I saw your response, I went my way and came up with another solution using two liner plugin code which filters the paring characters and replacing them. This is attached to onWebPagePrerender event. the code looks like this.
        $output = & $modx->resource->_output;
        $output= preg_replace(array("/\[{/","/}\]/"),array("[[","]]"),$output);
        


        So when showing on the page rather than executing, I would write [{snippet}] and it will be shown as [[snippet]].

        <fixedpre></fixedpre> solution presented in that topic does excatly what I was doing manually and it attaches to the time of document parsing (that is, to convert the targeted characters into html codes) and it is more generalized. This is more elegant solution. why did'nt I think of that? smiley