View Full Version : Calling a new template from forumdisplay
TimberFloorAu
Wed 18th Feb '09, 6:34pm
I notice, in our templates we have such things as $navbar.
Which presumably calls the template "navbar" and includes it within the referring page.
Does this template though, need a corresponding php file, called navbar.php or does it work on the $ call.
If so, I created a template called , example: mytemplate
I then tried to call that template inclusion, by using $mytemplate
however it isnt showing, am I missing something painfully obvious?
Regards Ste
Lynne
Wed 18th Feb '09, 6:43pm
navbar does not have a corresponding navbar.php. The template does, however, get 'evaled' for use in the page which is what must happen with any template you wish to call on a page:
eval('$myvariable .= "' . fetch_template('my_template') . '";');
TimberFloorAu
Wed 18th Feb '09, 7:01pm
So can you explain, how and where we can add and customize that code please lynn ?
TimberFloorAu
Wed 18th Feb '09, 7:39pm
I have tried:
eval('$news = "' . fetch_template('news') . '";');
that doesnt seem to work ( code lifted from the manual )
Lynne
Wed 18th Feb '09, 7:44pm
Well, you need to have a template called 'news' and then you need to eval that template prior to evaling the template that uses the variable $news.
For instance, if you are using $news in the FORUMDISPLAY template, then you need to have that eval line before the FORUMDISPLAY template is evaled.
TimberFloorAu
Thu 19th Feb '09, 5:29pm
Well, you need to have a template called 'news' and then you need to eval that template prior to evaling the template that uses the variable $news.
For instance, if you are using $news in the FORUMDISPLAY template, then you need to have that eval line before the FORUMDISPLAY template is evaled.
Ok with you until the last bit... apologies.
how can i eval the line before the forumdisplay.
Im not sure on what template calls forumdisplay to thus eval the new template , for inclusion within forumdisplay by using the $news call.
Lynne
Thu 19th Feb '09, 6:29pm
If you are using $news in a template like FORUMDISPLAY, then do a search in the files to find where FORUMDISPLAY is evaled. Then, make sure you put your template eval *before* that. You will have to look at the code to figure this out.
(Doing a quick search for "FORUMDISPLAY" (case sensitive) in the 3.8 files just gives me 3 hits. Two are in forumdisplay.php and one is the eval statement on line 1066)
TimberFloorAu
Thu 19th Feb '09, 7:20pm
If you are using $news in a template like FORUMDISPLAY, then do a search in the files to find where FORUMDISPLAY is evaled. Then, make sure you put your template eval *before* that. You will have to look at the code to figure this out.
(Doing a quick search for "FORUMDISPLAY" (case sensitive) in the 3.8 files just gives me 3 hits. Two are in forumdisplay.php and one is the eval statement on line 1066)
Thanks Lynne. Will go have a play :) !
Powered by vBulletin™ Version 4.0.0 Beta 4 Copyright © 2009 vBulletin Solutions, Inc. All rights