PDA

View Full Version : Calling a template on command line


WeBBy
12-17-2003, 07:05 PM
What UI am trying to do is call a specific template from the command line, something like...

http://mysite.com/forum/index.php?template=forumhome
http://mysite.com/forum/index.php?template=articlehome
http://mysite.com/forum/index.php?template=marketinghome
http://mysite.com/forum/index.php?template=whateva

I imagine I need some sort of moderator in index.php to do this. Can anyone help me out?

Thanx

g-force2k2
12-17-2003, 08:55 PM
This code should achieve the effect that you're looking for.
if ( $template )
{
eval ( "dooutput ( \"" . gettemplate ( $template ) . "\" ) ;" ) ;
}

Regards,
g-force2k2

WeBBy
12-17-2003, 09:17 PM
SWEET !!!! :D

Thank you m8 - works perfect! Just the ticket I needed. If I leave in the
eval("dooutput(\"".gettemplate('forumhome')."\");");
then it defaults to forumhome if I dont specify the template=

Thanx again :D

g-force2k2
12-17-2003, 09:22 PM
Hey no problem glad that you appreciate the help.

Regards,
g-force2k2

WeBBy
12-18-2003, 03:45 AM
Just noticed a minor problem (I was wrong above - spoke a little too soon)

If a Template is NOT specified, I get "<!-- // End of vbPortal calendar script " .. hmmmm

If I leave the eval("dooutput(\"".gettemplate('forumhome')."\");"); statement in, then I actually get both my called template and the forumhome template all on the same page.

This should be easy (but I am stupid), but I could use a statement to use forumhome if no template specified. That would really just be a fallback cause I am gonna specify a template with almost anything - more worried about the script making the call itself.

Tyhanx much again :D

WeBBy
12-19-2003, 05:01 AM
Any help on this one. What I need is a statement to go along with

if ( $template )
{
eval ( "dooutput ( \"" . gettemplate ( $template ) . "\" ) ;" ) ;
}

so that if template=null (i.e., no template called), the forumhome or other default template is used. As it stands now, if I just use index.php, I get a blank page because no template is used.

Thanx again if you can help :D

g-force2k2
12-19-2003, 11:32 AM
Its alright Webby, anyhow i recoded to fix the changes that you talked about and also added something to restrict calling a specific template on command so that they don't end up with a white page.

$main_temps = "forumhome,articlehome" ; // Add new valid template names here seperate by commas

$temp_arr = explode ( ",", $main_temps ) ;
if ( $template ) :
if ( !in_array ( $template, $temp_arr ) ) :
$template = "forumhome" ;
endif ;
else :
$template = "forumhome" ;
endif ;
eval ( "dooutput ( \"" . gettemplate ( $template ) . "\" ) ;" ) ;

Regards,
g-force2k2