PDA

View Full Version : Custom Variable


zwenthe
05-08-2007, 06:33 AM
Can someone help me out a little... lets say I want to create a variable for "Company Name", and so everytime I include the variable in the template it includes the company name.

I figure I can add this variable to the config file... but I need to figure out how to call this variable inside the .tpl files.

I plan on making variations of my sites and this will lower my development time, since I can change the company name in just one location, instead of throughout the site.

Thoughts???

utvara
05-08-2007, 10:43 AM
if your variable is $company_name you should assign it to template manager by adding following code


$template_manager->assign($company_name,'/{COMPANY_NAME}/');


best place for this code is in include/box_definitions.php (3.5 clean install), or include/includes.php (3.4 upgraded) after

$template_manager = new template();

Now you will be able to access company_name trough {COMPANY_NAME} in your templates.

Hope it helps.

zwenthe
05-08-2007, 05:12 PM
if I wanted to create a variableconfig file and define my variables all there, all I would need to do is include that in includes/include.php or include/box_definitions.php right? or would I need to include that file in other places as well?

utvara
05-09-2007, 09:48 AM
if I wanted to create a variableconfig file and define my variables all there, all I would need to do is include that in includes/include.php or include/box_definitions.php right? or would I need to include that file in other places as well?

include.php is good place to include your variableconfig.php. Also good place to add your custom variables is conf.php because it will never be included in any upgrade or security patch.