I'm creating a mobile template for my website using the goMobile contribution as a starting point.
goMobile overrides the template with a '_mobile' suffix when viewing the site on a mobile device.
I have an issue where I could do with the ability to override the /modules/pages/... files to be template specific.
I know you can't do this on standard Zen as I've seen a few threads asking for the same thing, but I've tweaked a couple of files and I seem to have it working.
Trouble is, it seems too easy and I'm sure I've probably messed something up that I just haven't noticed yet!
Can one of the gurus please take a look at the following code changes and see if anything springs to mind that I may have broken?
There's only 2 files with minimal code changes. I've marked the code changes between comments like this
//bof pages template override x of x
//eof pages template override x of x
First file is includes/init_includes/overrides/init_sanitize.php right down at the bottom
Second file is includes/auto_loaders/overrides/config.core.php around line 170, in which I had to change the order init_sanitize.php was called as it now uses the variable $template_dir which is set in init_templates.phpCode:/** * We do some checks here to ensure $_GET['main_page'] has a sane value */ if (!isset($_GET['main_page']) || !zen_not_null($_GET['main_page'])) $_GET['main_page'] = 'index'; //bof pages template override 1 of 2 if (!is_dir(DIR_WS_MODULES . 'pages/' . $_GET['main_page']) && !is_dir(DIR_WS_MODULES . 'pages/' . $template_dir . '/' . $_GET['main_page'])) { //eof pages template override 1 of 2 if (MISSING_PAGE_CHECK == 'On' || MISSING_PAGE_CHECK == 'true') { $_GET['main_page'] = 'index'; } elseif (MISSING_PAGE_CHECK == 'Page Not Found') { header('HTTP/1.1 404 Not Found'); $_GET['main_page'] = 'page_not_found'; } } $current_page = $_GET['main_page']; $current_page_base = $current_page; //bof pages template override 2 of 2 if (is_dir(DIR_WS_MODULES . 'pages/' . $template_dir . '/' . $current_page_base)) $code_page_directory = DIR_WS_MODULES . 'pages/' . $template_dir . '/' . $current_page_base; else $code_page_directory = DIR_WS_MODULES . 'pages/' . $current_page_base; //eof pages template override 2 of 2 $page_directory = $code_page_directory;
It all seems too easy to me! My biggest worry is changing the load order in config.core.php. I'm pretty confident the change to init_sanitize.php shouldn't cause a problem, but if anyone can cast their eye over this I'd appreciate it!Code:/** * Breakpoint 100. * * require('includes/init_includes/init_sanitize.php'); * $template = new template_func(); * */ //bof pages template override 1 of 1 $autoLoadConfig[100][] = array('autoType'=>'classInstantiate', 'className'=>'template_func', 'objectName'=>'template'); /** * Breakpoint 110. * * require('includes/init_includes/init_languages.php'); * require('includes/init_includes/init_templates.php'); * */ $autoLoadConfig[110][] = array('autoType'=>'init_script', 'loadFile'=> 'init_languages.php'); $autoLoadConfig[110][] = array('autoType'=>'init_script', 'loadFile'=> 'init_templates.php'); $autoLoadConfig[110][] = array('autoType'=>'init_script', 'loadFile'=> 'init_sanitize.php'); //eof pages template override 1 of 1 /** * Breakpoint 120. * * $_SESSION['navigation']->add_current_page(); * require('includes/init_includes/init_currencies.php'); * */


Reply With Quote
