Search code examples
modxmodx-revolution

Display ModX placeholders as code in ModX resource?


I want to share some ModX template code I've made on my ModX site. I can paste the html in fine using <pre> but the chunks, eg [[$footer]] [[$header]] and placeholders, eg [[*content]] still display as ModX Placeholders meaning I see the contents of [[$header]] rather than just the code.

Does anyone know I way I can display placeholder and chunk code/hooks within a ModX resource?


Solution

  • Here is the solution mentioned by okiyanet in more detail. Create a snippet convertModxTags and place this code inside:

    <?php
    $output = str_replace('[[','&#91;&#91;',$input);
    return $output;
    

    Then call it in your template:

    [[!convertModxTags?&input=`[[*content]]`]]
    

    or

    [[*content:convertModxTags]]