Как получить контент страницы перед рендером всех тегов и вызовов?

Как получить страницу с тегами в таком состоянии [[*id]] перед рендером?, чтобы что-то заменить.
Пробовал так, но никак не могу понять как получить весь контент страницы

switch ($modx->event->name) {
    case 'OnWebPageInit':
        $output = get_class_methods($modx);
        $modx->log(1, print_r($output), 'HTML');
        break;
}

И так
$output = &$modx->resource
&$modx->resource->_output;
Vladimir
15 мая 2022, 20:07
modx.pro
801
0

Комментарии: 3

Vladimir
15 мая 2022, 20:22
0
Пробовал так
switch ($modx->event->name) {
case 'OnWebPageComplete':
//Получаем доступ к готовому DOM дереву
$output = $modx->resource->getContent();
$modx->log(1, output );
break;
}

Но получаю не полностью сам контент страницы, а часть покрайней мере так в консоли, видел в консоле 1 вызов [[++settings_version]]

То есть какой-то сжатый кусок, сама страница дефолтная от установки modx'a, но получаю сжатый такой кусок в таком виде. Сохранил вывод с
$modx->resource->getContent();
в файл.

<p>You have successfully installed MODX Revolution [[++settings_version]]!</p>
<p>Now that MODX is installed you can login to the manager to create your templates, manage content and install third party extras to add functionality to your website.</p>
<h2>New to MODX?</h2>
<p>Pages on a MODX site are called <a href="https://docs.modx.com/current/en/building-sites/resources">Resources</a>, and are visible on the left-hand side of the manager in the Resources tab. Resources can be nested under other resources, making it easy to create a tree of resources. There are different types of resources for different use cases.</p>
<p>Building your website is done through a combination of <strong>Templates</strong>, <strong>Template Variables</strong>, <strong>Chunks</strong>, <strong>Snippets</strong> and <strong>Plugins</strong>. Collectively these are known as <strong>Elements</strong>, and can also be found in the left-hand side of the manager, in the Elements tab.</p>
<p><a href="https://docs.modx.com/current/en/building-sites/elements/templates">Templates</a> contain the outer markup of any page. Each resource can only be assigned to a single template at a time. By adding <a href="https://docs.modx.com/current/en/building-sites/elements/template-variables">Template Variables</a> to a template, you can add custom fields for any resource using that particular template.</p>
<p>With <a href="https://docs.modx.com/current/en/building-sites/elements/chunks">Chunks</a> you can share parts of the markup, such as a header, across different templates. <a href="https://docs.modx.com/current/en/building-sites/elements/snippets">Snippets</a> are pieces of PHP that return dynamic content, such as summaries of other resources or the current date. With snippets, you will often use Chunks to mark up the pieces of content it returns, instead of mixing the PHP and HTML.</p>
<p>Finally, <a href="https://docs.modx.com/current/en/extending-modx/plugins">Plugins</a> enable more advanced features by hooking into the extensive events system provided by MODX.</p>
<p>To learn more about MODX, be sure to check out the <a href="https://docs.modx.com/current/en/getting-started">Getting Started</a> section in the official documentation.</p>
А это получается что я получаю именно контент самого ресурса а не контент шаблона перед рендером
    Артур Шевченко
    16 мая 2022, 22:01
    0
    Если шаблон в файле можно получить содержимое файла file_get_contents(). Если в БД, можно получить $modx->getObject('modTemplate', $templateId); Но Роман задал хороший вопрос: зачем тебе содержимое шаблона до парсинга?
    Роман
    16 мая 2022, 10:20
    0
    Если правильно понял:
    Можно поместить контент в отдельный чанк, и вызывать OnChunkFormRender.
    Если нужно чтобы уже вся страница создалась, то вызов OnWebPagePrerender

    А так что вы хотите сделать? Какая конечная цель?
      Авторизуйтесь или зарегистрируйтесь, чтобы оставлять комментарии.
      3