PDA

View Full Version : header template


Murtific
07-20-2011, 04:38 AM
where in the WORLD is this thing......... I even tried renaming it and it looks like it got "recreated" if it wasn't there.

I was trying to get the {vb:raw header} thingy so I could make my own custom header... I really really really want to do my own custom header. I REALLY dont want to go into each template on the dang thing and remove {vb:raw header} and replace with the WHOLE entire "header template code"... That's the only way i can get my customizations in the header to appear anywhere on the board.. That's what I did for FORUMHOME template and it works fine only on the main page :eek:

kh99
07-20-2011, 10:41 AM
It should just be the header template - are you sure you're editing the right one for the style you're using?

Murtific
07-20-2011, 01:48 PM
lol.. ok answer me this then. How do you make your own custom header and still able to use {vb:raw mycustomheader} so the header shows up in templates.

kh99
07-20-2011, 02:03 PM
You lost me...maybe. I'm not sure why 'lol', did I answer the wrong question? If you want to make a custom header you should just be able to edit the header template.

I was about to answer the above question about using {vb:raw mycustomheader} by refering you to the article on templates, but I see you found that already. BirdOfPrey5 asked what hook you used for your plugin - that's a good question because the header is rendered kind of early on, so if you don't choose a hook before that then you won't see anything. ETA: hook parse_templates is just before where the header template is rendered, so that might be a good one.

--------------- Added 1311178575 at 1311178575 ---------------

OK, I saw what you posted in the other thread, and I guess you're not using plugins.

Instead, create a plugin in the adminCP by going to Plugins & Products -> Add New Plugin. Select hook location parse_templates from the dropdown and paste your code in the box. Put a title in so you'll remember what this does, and select the "Yes" radio button to enable the plugin (you should be able to leave the other fields as they are). ETA...oh yeah, and then press "Save" or "Save and Reload".

BTW, what I posted about it being too late to affect the header after global.php was wrong (I was thinking vb3), but you still want to use a plugin so that you don't have to change the php for every page.

Murtific
07-20-2011, 04:01 PM
//apth_p.php has my connection info
require_once("apth_p.php");
if(!$connection) {
die("Database connection failed:: connection: " . mysql_error());
}
$db_select = mysql_select_db("Tim", $connection);
if (!$db_select) {
die("Database selection failed to select: " . mysql_error());
}
$eventlist = mysql_query("SELECT * FROM thread WHERE forumid = 8 ORDER BY dateline DESC", $connection);
if (!$eventlist) {
die("Database selection failedquery:eventlist: " . mysql_error());
}
while ($row = mysql_fetch_array($eventlist)) {
$zthreadid .= $row["threadid"];
$zdateline .= $row["dateline"]."<br />";
$zlink .= "<a href='showthread.php?{$row["threadid"]}'>" . $row["title"]."</a>" . "<br />";

}

mysql_close($connection);

$templater->register('zlink', $zlink);
$templater->register('zthreadid', $zthreadid);
$templater->register('zdateline', $zdateline);


It blanks out my forum.php page. I want to use the variables in my header

kh99
07-20-2011, 04:35 PM
In the code you just posted, you're never initializing $templater. So you either want to go back to the code you had (using a 'threads' template), or else use preRegister like:

vB_Template::preRegister('header',array('zlink' => $zlink,
'zthreadid' => $zthreadid,
'zdateline' => $zdateline));


then use {vb:raw zlink} etc in the header template.

Murtific
07-20-2011, 04:37 PM
elaborate on initializing $templater?
i added that and still doesn't work.

white page.

closest i had was, but it looked all jacked up
$templater = vB_Template::create('header');

it displayed some data but forum looked jacked up

kh99
07-20-2011, 04:43 PM
elaborate on initializing $templater?

In the code you originally posted in the article thread you had:

$templater = vB_Template::create('threads');
$templater->register('zthreadid', $zthreadid);
$templater->register('zlink', $zlink);
$templater->register('zdateline', $zdateline);
$zlink2['$zlink'] = $templater->render();
vB_Template::preRegister('header',array('zlink2' => $zlink2));

so you can see that the first line is creating a vB_Template object. In the code above you don't have that line but you're still using $templater as if it were set to an object.


i added that and still doesn't work.

white page.


A white page usually means there's some error in the code (I suppose that's obvious), but it's hard to debug code just by looking at part of it. I don't see anything wrong with what you posted (maybe someone else will).

Are you using a plugin or still working in forum.php?

Murtific
07-20-2011, 04:48 PM
LOL looks like i had it all along.... dunno what i did wrong the first time tho. it works now like a champ. probably the hook....... thanks man!

--------------- Added 1311184884 at 1311184884 ---------------

works, but now all my external php page database stuff is all messed up

--------------- Added 1311188053 at 1311188053 ---------------

There has to be another method than parse_template hook. this hook just screws up all my coding for the forum. No doubt this does work. But it really is nasty to the rest of the board.

--------------- Added 1311189606 at 1311189606 ---------------

i had my database code in the header plugin i made closing the database connection.. that was the fault. so before my other pages opend up to call up database info, it would fail..