Skip to content

Instantly share code, notes, and snippets.

@andronex
Last active October 9, 2019 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save andronex/e183903dcc331f154b25c8f79db81156 to your computer and use it in GitHub Desktop.
Save andronex/e183903dcc331f154b25c8f79db81156 to your computer and use it in GitHub Desktop.
Добавление к title или alt атрибутам HTML тегов произвольного постфикса, например, названия сайта/компании.
<?php
if ($modx->event->name == "OnWebPagePrerender") {
$output = &$modx->resource->_output;
$postfix = $modx->getOption('title_postfix');
$output = preg_replace('/title="([\s\S]*?)"/ui', 'title="$1 '.$postfix.'"', $output);
$output = str_replace('title=" | Энергоматика', 'title="Энергоматика', $output);
}
return;
<?php
/*
* добавление постфикса в title страницы
*/
if ($modx->event->name == "OnWebPagePrerender") {
$output = &$modx->resource->_output;
$postfix = $modx->getOption('title_postfix');
$output = preg_replace('/<title>([\s\S]*?)<\/title>/ui', '<title>$1 '.$postfix.'</title>', $output);
}
return;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment