D
D
Dmitry Smirnov2017-03-03 15:05:55
MODX
Dmitry Smirnov, 2017-03-03 15:05:55

Embed code on some pages of a modx site?

Good afternoon!
First time working with modx. I'm trying to accomplish the following task:
on some pages (not all), I need to set the code in the head section.
With a cursory study, I realized that you can make a new template = old + new code to be inserted. But it seems to me that the solution is not the best.
Please tell me how can I solve my problem?
That is, it is desirable to prescribe some kind of condition that is triggered on certain pages and inserts the desired code.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
anton_lazarev, 2017-03-03
@anton_lazarev

You can make a snippet like this:

<?php
$resources = explode(',', $resources);
 
if (in_array($modx->resource->get('id'), $resources)) {
  return 'block of code';
}

Then call the snippet in the header chunk and specify the necessary resources:

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question