Jump to content

Create a global Smarty variable?


iangutjahr

Recommended Posts

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!!

Link to comment
Share on other sites

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 by iangutjahr
Link to comment
Share on other sites

  • 6 months later...

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated