PDA

View Full Version : Dynamically add meta keywords on custom pages


Zahl
06-27-2008, 07:28 AM
Hi there,

I have a custom page in my vB and I want to add meta keywords depending on what I'm
outputting. I tried doing stuff like $vb->options/$vboptions['keywords'] .= ', new keyword'; before I fetched any templates or did any output, but the keywords won't be
added, so it seems the headerinclude template already gets parsed when I just include
global.php
Any way to get around this? Thanks :)

Dismounted
06-27-2008, 10:10 AM
You can add conditionals in the headinclude template to do this.

Zahl
06-27-2008, 01:21 PM
OK, I tries this, but no luck. It really seems like the headerinclude template gets parsed before any of my code gets executed, so the conditional that checks for my stuff always finds nothing.... Any ideas what I'm doing wrong?

I'll take a look at the threadview stuff now, as it is using conditionals too....

--------------- Added 1214578283 at 1214578283 ---------------

OK, this is my solution now:
I added headinclude to the global templates
I add keywords via
$vbulletin->options['keywords'] .= ', my keyword';
And then I do a
eval('$headinclude = "' . fetch_template('headinclude') . '";');
before I fetch the final page template that uses $headinclude...

Dismounted
06-28-2008, 05:15 AM
Use the parse_templates hook to do whatever you need to. Then you can use data from that hook in headinclude.

Opserty
06-28-2008, 09:35 AM
Just edit the headinclude template directly and add the HTML you want to.