PDA

View Full Version : php code to output contents of a template


skor
12-05-2010, 07:34 PM
I have a template with just text that I want to output to a specific hook location.

What php code would I use to do this?

I tried this but not sure if eval is the right thing to use here.

eval('$template_hook[\'postbit_userinfo_right_after_posts\'] .= "' . fetch_template('postbit_garagelinktitle') . '";');

All I want to do is print the text "Link title" at that hook location. I'm not even sure if I need to use a template to do this or if i can just do some sort of print statement to do it.

As you can see, I'm a noob without a clue. lol

Thanks in advance for any help!

For reference, here is the complete plugin I am trying to edit...it is part of the garage mod that outputs a link to the vehicle in the postbit. I tried to put the text in the template that was created by the plugin but then it prints the "Link title" text above each vehicle if a user has more than one vehicle in the postbit.

global $vbulletin;
if(THIS_SCRIPT == 'showpost' OR THIS_SCRIPT == 'showthread')
{
switch ($vbulletin->options['postbittype'])
{
case 1: $pbq = "ORDER BY `main_vehicle` DESC LIMIT 1"; break;
case 2: $pbq = "ORDER BY `main_vehicle` DESC LIMIT 1"; break;
case 3: $pbq = "ORDER BY `vehicle_id` DESC LIMIT 10"; break;
}
$sql = $this->registry->db->query("select *, " . TABLE_PREFIX . "garage_user_vehicle.user_id AS PostUser
from " . TABLE_PREFIX . "garage_user_vehicle
LEFT JOIN " .TABLE_PREFIX . "garage_makes
on (" .TABLE_PREFIX . "garage_user_vehicle.make_id=" .TABLE_PREFIX . "garage_makes.id)
LEFT JOIN " .TABLE_PREFIX . "garage_models
on (" .TABLE_PREFIX . "garage_user_vehicle.model_id=" .TABLE_PREFIX . "garage_models.id)
WHERE " . TABLE_PREFIX . "garage_user_vehicle.user_id='" . $post['userid'] ."' " . $pbq);

if($this->registry->db->num_rows($sql) > 0)
{
********THIS IS THE PART I ADDED************
eval('$template_hook[\'postbit_userinfo_right_after_posts\'] .= "' . fetch_template('postbit_garagelinktitle') . '";');
********/ THIS IS THE PART I ADDED************
if($vbulletin->options['postbittype'] >= 3)
{
print("What is in my garage");
while ($entry = $this->registry->db->fetch_array($sql))
{
$newyr = substr($entry[made_year], -2);
eval('$template_hook[\'postbit_userinfo_right_after_posts\'] .= "' . fetch_template('postbit_garagelink') . '";');
}
} else {
$entry = $this->registry->db->fetch_array($sql);
$newyr = substr($entry[made_year], -2);
eval('$template_hook[\'postbit_userinfo_right_after_posts\'] .= "' . fetch_template('postbit_garagelink') . '";');
}
}
}

Lynne
12-05-2010, 08:25 PM
Cellarius wrote a really good article that you may be interested in - [vB4] Rendering templates and registering variables - a short guide (https://vborg.vbsupport.ru/showthread.php?t=228078)

skor
12-05-2010, 09:20 PM
Cellarius wrote a really good article that you may be interested in - [vB4] Rendering templates and registering variables - a short guide (https://vborg.vbsupport.ru/showthread.php?t=228078)

Thank you for the link. I am working with vb3 but the example he had for the outdated code for vb3 I think leads me to think I did it correctly. ...I hope... :)

Lynne
12-05-2010, 10:08 PM
You didn't mark this as vB3, so I didn't really know.

Also, this forum is generally for requesting someone to write an actual modification, not for help with the code. Help with coding is usually in the programming discussions, or if a general question about the code, then the general discussions forum for the version you are working on.

skor
12-06-2010, 01:30 AM
Oops sorry about that. Please move to appropriate forum. I was afraid I was posting in the wrong forum but wasn't completely sure. Thank you.