PDA

View Full Version : How do i make a variable?


dricho
07-22-2007, 05:23 PM
I'm new to modifying templates, and am currently trying to make a different head for certain modifications. I know that the $header variable displays header code found under the header style template, but say i wanted to make a variable $header_articles how would i set it up so it displays the template code found in header_articles

I hope this make sense.. lol i'm not the brightest when it comes to coding terms....

EDIT: i'm almost certain it aint a phrase...

EnIgMa1234
07-22-2007, 05:32 PM
Cache and parse the template then use a replacement variable to change $header to $yourvariable

Kirk Y
07-22-2007, 05:36 PM
Create a new template containing what you'd like displayed when your variable is used.

Create a hook using location "global_start" with the following:
eval('$myvar = "' . fetch_template('mytemplate') . '";');Replace "myvar" and "mytemplate" accordingly.

Anywhere you use $myvar in a template, the contents of mytemplate will be executed.

To cache the template, create a new plugin at hook location "cache_templates" with the following:
$globaltemplates[] = 'mytemplate';Again, replacing "mytemplate" with your template name.

dricho
07-22-2007, 10:11 PM
Thank you so much kirk, that was a really great guide and i appreciate it immensely!

Kirk Y
07-22-2007, 10:35 PM
No problem.