2022-12-05 21:39:13 +00:00
|
|
|
<?php
|
|
|
|
|
2022-12-05 21:42:34 +00:00
|
|
|
if (!defined('DC_RC_PATH')) {
|
|
|
|
return null;
|
|
|
|
}
|
2022-12-05 21:39:13 +00:00
|
|
|
|
2022-12-05 21:42:34 +00:00
|
|
|
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), dcCore::app()->templator->path);
|
|
|
|
dcCore::app()->addBehavior('urlHandlerBeforeGetData', ['publicTemplatorBehaviors','BeforeGetData']);
|
2022-12-05 21:39:13 +00:00
|
|
|
|
|
|
|
class publicTemplatorBehaviors
|
|
|
|
{
|
2022-12-05 21:42:34 +00:00
|
|
|
public static function BeforeGetData($_)
|
|
|
|
{
|
|
|
|
if (array_key_exists(dcCore::app()->url->type, dcCore::app()->getPostTypes()) || dcCore::app()->url->type == 'pages') {
|
|
|
|
$params = [];
|
|
|
|
$params['meta_type'] = 'template';
|
|
|
|
$params['post_id'] = dcCore::app()->ctx->posts->post_id;
|
|
|
|
$post_meta = dcCore::app()->meta->getMetadata($params);
|
|
|
|
|
|
|
|
if (!$post_meta->isEmpty() && dcCore::app()->tpl->getFilePath($post_meta->meta_id)) {
|
|
|
|
dcCore::app()->ctx->current_tpl = $post_meta->meta_id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dcCore::app()->ctx->current_tpl == 'category.html' && preg_match('/^[0-9]{1,}/', dcCore::app()->ctx->categories->cat_id, $cat_id)) {
|
|
|
|
$tpl = 'category-' . $cat_id[0] . '.html';
|
|
|
|
if (dcCore::app()->tpl->getFilePath($tpl)) {
|
|
|
|
dcCore::app()->ctx->current_tpl = $tpl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-12-05 21:39:13 +00:00
|
|
|
}
|