Zen Cart Logo
Forums / General Questions / trying to find the link to a file

trying to find the link to a file

Locked

Views: 2,536

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
6 Jul 2007, 8:14 AM
#1
chrome_orange avatar

chrome_orange

Totally Zenned

Join Date:
Jun 2004
Posts:
457
Plugin Contributions:
0

trying to find the link to a file

ok

which file 'includes' or 'requires'

/includes/modules/pages/index/main_template_vars.php

basically I am using the multisite add on and would like two versions of that file so that I can display things slightly differently (I am wanting to split the product name and product description for one site but not the other)

option 2 is to rewrite the original template to use the modified main_template_vars

TIA

6 Jul 2007, 8:53 AM
#2
chrome_orange avatar

chrome_orange

Totally Zenned

Join Date:
Jun 2004
Posts:
457
Plugin Contributions:
0

Re: trying to find the link to a file

I have solved my problem

after posting I found this

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';
  }

in includes/templates/template_default/common/main_template_vars.php

by replacing that code with

if (file_exists(DIR_WS_MODULES. $template_dir  .'/pages/' .$current_page_base . '/main_template_vars.php')) {
    $body_code = DIR_WS_MODULES. $template_dir  .'/pages/' .$current_page_base . '/main_template_vars.php';
} elseif (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';
}

it works for me.

I haven't tested it on other 'main_template_vars.php' files but this might answer this question

http://www.zen-cart.com/forum/showthread.php?t=67898

6 Jul 2007, 8:59 AM
#3
chrome_orange avatar

chrome_orange

Totally Zenned

Join Date:
Jun 2004
Posts:
457
Plugin Contributions:
0

Re: trying to find the link to a file

just so it's clear

the original main_template_vars.php file is here

includes/modules/pages/index/main_template_vars.php

the modified file goes here

includes/modules/YOUR TEMPLATE NAME/pages/index/main_template_vars.php

seems to be working so far

6 Jul 2007, 9:10 AM
#4
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: trying to find the link to a file

An interesting idea. And since (I'm guessing) includes/templates/template_default/common/main_template_vars.php itself can be over-ridden, you have found a way to over-ride these rather key modules pages, completely via the over-ride system.

I will have a go at retrofitting this to a large project that I have been working on recently and see how it goes.

6 Jul 2007, 12:26 PM
#5
chrome_orange avatar

chrome_orange

Totally Zenned

Join Date:
Jun 2004
Posts:
457
Plugin Contributions:
0

Re: trying to find the link to a file

Hi kuroi
let me know how it goes.

I think that my clarification post might have made things more confusing!

so.

I want to be able to modify files in the modules/pages directory, files that are not normally included in the templating system eg

includes/modules/pages/index/main_template_vars.php

this file is accessed by one of the template files

includes/templates/template_default/common/main_template_vars.php

so I modify includes/templates/template_default/common/main_template_vars.php

with the code above.

Once I have done that I am able to create template specific module files like
includes/modules/MY_TEMPLATE/pages/index/main_template_vars.php

hopefully it's a little clearer.