2
votes

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?

4

4 Answers

2
votes

You could swap out the brackets with the relevant HTML codes to prevent them being parsed by MODX.

  • [[ becomes &#91;&#91;
  • ]] becomes &#93;&#93;

If you need to do this regularly you might look at writing a plugin to do this for you, perhaps running a string replace whenever you save your resources.

2
votes

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]]
0
votes

Have a look at this plugin for Revo: http://www.modx360.com/blog/2010/02/12/prevent-parsing-modx-tags/

Create it as an PlugIn, do not forget to tip on: OnLoadWebDocument OnWebPagePrerender OnBeforeSaveWebPageCache

And paste your REVO-MODX-code on your page between two code-elements.

0
votes

There are two extras that will do this for you:

The FixedPre plugin will show both MODX and HTML tags inside of fixedpre tags.

The SyntaxHighlighter plugin or snippet will do the same, but will also highlight the code and put it in a separate block.