iangutjahr Posted August 25, 2011 Share Posted August 25, 2011 I'm trying to create my own variables so I can use them throughout the site. so far what I've done is made my own function file in /includes/ <?php function packagePrice ($id, $term) { #get info here $price = "$8.00"; return $price; } ?> and then in my php file (where it loads the template file) I put: require "includes/customfunctions.php"; $smartyvalues['m_price'] = packagePrice (1, "monthly"); So, what I want to do is make my function and define my variables in the customfunctions.php file so that I dont have to create the smarty variable on every page. Creating a global smarty variable that can be used for every template file.. Hopefully this makes sense! Thanks alot!! 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted August 25, 2011 Share Posted August 25, 2011 You could probably create an actionhook with ClientAreaPage, and then do something like this. global $smarty; $smarty->assign('foo', $bar); 0 Quote Link to comment Share on other sites More sharing options...
iangutjahr Posted August 28, 2011 Author Share Posted August 28, 2011 (edited) I got that working great on all my pages execpt the main index page. I'm unsure on how to add variables to that page. I've searched the docs and the forums and have found answers to a lot of other questions that I've had but nothing on where to add $smartyvalues["var"] = $foo; to work in the main page. Everything I've tried so far has not worked. Any ideas? Just noticed in your sig you have ASO listed! They were one of my first hosts! ASO is awesome!! Edited August 28, 2011 by iangutjahr 0 Quote Link to comment Share on other sites More sharing options...
dybfm Posted March 21, 2012 Share Posted March 21, 2012 I need this also 0 Quote Link to comment Share on other sites More sharing options...
leemason Posted March 22, 2012 Share Posted March 22, 2012 just create a hooks file in the includes/hooks folder create a function, and hook it to the ClientAreaPage function sas frank suggested, but do it like this: function test_hook($vars){ $vars['newglobal'] = 'value'; returns $vars; } add_hook("ClientAreaPage",1,"test_hook"); obviouslt change the function name as it should be named the same as the hook file 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.