Как правильно написать плагин?
Привет. Подскажите, как правильно написать плагин?
Плагин подменяет шаблон под AMP страници по гет запросу modx.pro/help/12866
3
Плагин подменяет шаблон под AMP страници по гет запросу modx.pro/help/12866
<?php
$id = $modx->resource->get('id'); // Get current page id
$resource = $modx->getObject('modResource',$id); // Get current object
$template = $modx->resource->template; // Get current page template
if($template == 5 && isset($_GET['amp'])) {
$modx->resource->set('template', 30);
}
if($template == 7 && isset($_GET['amp'])) {
$modx->resource->set('template', 30);
}
if($template == 6 && isset($_GET['amp'])) {
$modx->resource->set('template', 30);
}
if($template == 8 && isset($_GET['amp'])) {
$modx->resource->set('template', 30);
}
$modx->resource->cacheable = false; // Disable cache
Комментарии: 3