Zen Cart Logo
Forums / Bug Reports / [Not a bug] Can't override pages/specials/main_template_vars.php

[Not a bug] Can't override pages/specials/main_template_vars.php

Locked

Views: 1,521

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
7 Jun 2010, 1:21 AM
#1
cmlacy avatar

cmlacy

New Zenner

Join Date:
Jun 2010
Posts:
2
Plugin Contributions:
0

[Not a bug] Can't override pages/specials/main_template_vars.php

I'm using 1.3.9a, and I wasn't able to make a theme-specific override to includes/modules/pages/specials/main_template_vars.php.

The flaw appears to be in includes/templates/template_default/common/main_template_vars.php - when it does its check for the "special" page's source file, it looks for:

DIR_WS_MODULES . 'pages/' . $current_page_base . '/main_template_vars.php'

Now DIR_WS_MODULES is 'includes/modules', and $current_page_base is 'specials'. There's no check for a per-theme override.

I worked around it by overriding includes/templates/template_default/common/main_template_vars.php and making it look like this:

<?php
if (file_exists(DIR_WS_MODULES . 'mytheme/pages/' . $current_page_base . '/main_template_vars.php')) {
  $body_code = DIR_WS_MODULES . 'mytheme/pages/' . $current_page_base . '/main_template_vars.php';
} else if (file_exists(DIR_WS_MODULES . 'pages/' . $current_page_base . '/main_template_vars.php')) {
  $body_code = DIR_WS_MODULES . 'pages/' . $current_page_base . '/main_template_vars.php';
} else {
  $body_code = $template->get_template_dir('tpl_' . preg_replace('/.php/', '',$_GET['main_page']) . '_default.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_' . $_GET['main_page'] . '_default.php';
}
?>

I think it could be done in the default file in a more generic way, though. Probably by using "$template_dir" instead of the theme name?

7 Jun 2010, 2:51 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [Not a bug] Can't override pages/specials/main_template_vars.php

There was never any intent to have overrides of files under /includes/modules/pages/

Remember: any overrides you make STILL NEED TO BE UPGRADED whenever you upgrade your site.

8 Jun 2010, 12:25 AM
#3
cmlacy avatar

cmlacy

New Zenner

Join Date:
Jun 2010
Posts:
2
Plugin Contributions:
0

Re: [Not a bug] Can't override pages/specials/main_template_vars.php

Really? Why not? Since I can override almost an other file in the system based on theme name, it seems strange to deliberately leave a few out.