Advertisement
vanchelo

changeTemplateOnTheFly

Feb 5th, 2013
837
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1. if ($modx->event->name == 'OnWebPageInit' && isset($_GET['template'])) {
  2.     $template = (int) $_GET['template'];
  3.     // Допустимые шаблоны
  4.     if (!in_array($template, array(0,1,2))) return true;
  5.  
  6.     // Получаем ресурс
  7.     if (!is_object($modx->resource)) {
  8.         $modx->resource = $modx->request->getResource($modx->resourceMethod, $modx->resourceIdentifier);
  9.     }
  10.     // Меняем шаблон у ресурса
  11.     $modx->resource->template = $template;
  12.     // Делаем ресурс не кэшируемым
  13.     $modx->resource->cacheable = false;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement