Log in

View Full Version : Passing variable custom template - how? (Anyone here?)


xlguy
10-19-2004, 12:32 PM
vb3.0.3

In my .php file I have this:

if($bbuserinfo['userid'])
{
eval('$vbboxtop = "' . fetch_template('vbboxtop') . '";');
eval('$vbboxbot = "' . fetch_template('vbboxbot') . '";');
eval('print_output("' . fetch_template('premier') . '");');
}
else
{
print_no_permission();
}
Is there anyway of passing some details to the vbboxtop template (that's a custom one I made). I would like to specify a page title and pass that to vbboxtop. So my .php code might look like this:

if($bbuserinfo['userid'])
{
$mypagetitle = "This is the title";
eval('$vbboxtop = "' . fetch_template('vbboxtop') . '";'); XX pass $mypagetitle
eval('$vbboxbot = "' . fetch_template('vbboxbot') . '";');
eval('print_output("' . fetch_template('premier') . '");');
}
else
{
print_no_permission();
}

I need to know how to pass $mypagetitle to vbboxtop. That way when I edit the template in the AdminCP I can put $mypagetitle in the template and it will change the title depending on which of my custom .php pages is calling it.

Hope this makes sense... I know this site is quiet but any help would be great.

Colin F
10-19-2004, 12:41 PM
It seems what you did is right.

Just make sure the variable has a value, and then call it in the script using $mypagetitle

xlguy
10-19-2004, 12:43 PM
What I want to do is include $mypagetitle in a *template* in AdminCP not another .php file. I can't work out how you can pass variables to use in the templates. That's my question. Thanks :)

xlguy
10-19-2004, 12:51 PM
That's odd, I just tried it again and now it works... ROFL!

In my template I have:

<div align="center">
<div class="page" style="width:100%; text-align:left">
<div style="padding:0px 10px 0px 10px">

<table cellpadding="4" cellspacing="2" border="0" width="100%" align="center">
<thead><tr align="center"> <td class="thead" width="100%" align="left">$custompagetitle</td></tr></thead>
<tbody>
<tr>
<td class="alt1" align="left">

And I call it using:

if($bbuserinfo['userid'])
{
$custompagetitle = "This is the title";
eval('$vbboxtop = "' . fetch_template('vbboxtop') . '";');
eval('$vbboxbot = "' . fetch_template('vbboxbot') . '";');
eval('print_output("' . fetch_template('premier') . '");');
}
else
{
print_no_permission();
}
And it now works... which is strange/good. I guess that $custompagetitle is made available in all 3 templates I call now? Is that ok or should I do it in another way?

Colin F
10-19-2004, 01:26 PM
Exactly, all the $variables that have a value which is set before the call are available, because of the eval() I think.