Created
July 6, 2012 12:07
-
-
Save vanchelo/3059790 to your computer and use it in GitHub Desktop.
Pagebreaker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ($modx->Event->name == 'OnPageNotFound') { | |
$uri = $_SERVER['REQUEST_URI']; | |
// Обычный ресурс | |
if (preg_match("#(\.*?[a-z0-9_\-]+)_p(\d+)\.html#si", $uri, $m)) { | |
$alias = preg_replace("#(\.*?[a-z0-9_\-]+)_p(\d+)(\.html)#si", "$1$3", $uri); | |
$alias = substr($alias, 1, strlen($alias)); | |
} | |
// Контейнер | |
else if (preg_match("#(\.*?[a-z0-9_\-]+)/_p(\d+)\.html#si", $uri, $m)) { | |
$alias = preg_replace("#(\.*?/[a-z0-9_\-]+)/_p(\d+)(\.html)#si", "$1/", $uri); | |
$alias = substr($alias, 1, strlen($alias)); | |
} | |
if ($res = $modx->getObject('modResource', array('uri' => $alias))) { | |
$id = $res->get('id'); | |
$modx->sendForward($id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment