W
W
weranda2015-04-22 11:56:32
JavaScript
weranda, 2015-04-22 11:56:32

How to insert different code into a page in MODX so that it is displayed on the page?

Greetings.
Maybe someone has come across something similar or knows how it is implemented and will tell you possible options.
Anyone who uses MODX knows that when embedding a chunk, snippet and other calls, including third-party code, into a page (material), the MODX parser processes such code and displays its contents. You need to do it the way it is in many editors - escaping any code and then displaying it on the page. For example, if I write the code in the material:
Вопрос, then MODX will display the title of the material on the page, but I would like it to be displayed exactly as it is written:
Вопрос
Or, for example, I wrote the html code in the material and I need to make it appear on the page as the original html is unprocessed.
I tried various editors, but there is nothing like this in them. The only thing I found is Gist.github, but climbing there all the time and adding something, and then inserting the script into the site is extremely inconvenient. What options?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
K
keslo, 2015-04-22
@keslo

I did this:
- I connected Google Prettify from here
- in the MODx settings in CSS Selectors I created a style for the visual editor using the code codeprettify=prettyprint.
- when adding code, I frame it in this style.
Should work.
You can see it live on my blog .

W
weranda, 2015-04-22
@weranda

Just tried this one this morning. Maybe I'm doing something wrong? How I do it:
- I add prettify.js and prettify.css to the head of the template - I add it
to the body tag of the page onload="prettyPrint()"
- I add to the material, for example, <pre class="prettyprint">Вопрос</pre>
The page title is displayed, and not the written code itself.
What could be wrong?

R
Ruslan, 2015-06-05
@ruslan_aleev

Try https://modstore.pro/packages/content/jevix or https://modstore.pro/packages/content/markdown

I
Igor, 2016-01-27
@igamov

Hello. The same problem. The correction < on &lt;and > on &gt;
A helped or Вопросbrought it out &#91;&#91;*pagetitle&#93;&#93;Or [[*pagetitle]]
Found a better way !! Later I will throw off the link, as I add it to my blog, probably still relevant. He himself generates such code in the admin panel.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question