PDA

View Full Version : How to change the meta description? vboptions[description]?


Spinball
05-03-2011, 01:44 PM
Folks I have a custom template which I use to output custom pages outside normal forum functionality.
I want to change the keywords and description metas which in the headinclude look like
<meta name="description" content="$vboptions[description]" />
My php script does this at the top:
session_start();
error_reporting(E_ALL & ~E_NOTICE);
define('THIS_SCRIPT', 'reviews');
define('CSRF_PROTECTION', true);
$phrasegroups = array();
$specialtemplates = array();
$globaltemplates = array('custom_shell','headinclude');
$actiontemplates = array();
chdir("/home/sites/avforums/public_html/forums");
require_once('/home/sites/avforums/public_html/forums/global.php');
and after building the page into $page, then
eval('$navbar = "' . fetch_template('navbar') . '";');
$HTML = $page;
eval('print_output("' . fetch_template('custom_shell') . '");');


The template looks like this:
$stylevar[htmldoctype]
<html xmlns="http://www.w3.org/1999/xhtml" dir="$stylevar[textdirection]" lang="$stylevar[languagecode]" id="vbulletin_html">
<head>
<base href="http://www.avforums.com/forums/" />
$headinclude
<title>$pagetitle - $vboptions[bbtitle]</title>
<link href="http://www.avforums.com/styles/balloontip.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="http://www.avforums.com/highslide/highslide-with-html.js"></script>
<script type="text/javascript" src="http://www.avforums.com/highslide/highslide.config.js" charset="utf-8"></script>
<link rel="stylesheet" type="text/css" href="http://www.avforums.com/highslide/highslide.css" />
</head>
<body>
$header

<if condition="$headerbanner">$headerbanner</if>
$navbar

$HTML

<if condition="$footerbanner"><br />$footerbanner</if>
$footer
</body>
</html>

In the php script, I tried
$vbulletin->options['description'] = "AVForums reviews";
and
$vboptions['description'] = "AVForums reviews";

and neither work.
Any ideas please?

Spinball
05-05-2011, 08:33 AM
Anyone?

kh99
05-05-2011, 12:47 PM
Maybe you could make a plugin on hook parse_templates like this:
if (THIS_SCRIPT == 'reviews')
{
$vbulletin->options['description'] = "AVForums reviews";
}



Or maybe in your code you could do a preg_replace() on $headinclude after global.php is included, and replace the meta tags.

Spinball
05-05-2011, 08:47 PM
Thanks. It's not until I'm a bit into the script that I know what description I want to have. It's kind of a problem and I think I might have to create a custom version of global.php just for these special pages.

kh99
05-05-2011, 09:00 PM
OK, how about this: in the headinclude template put
<if condition="THIS_SCRIPT != 'reviews'">
...
</if>


around the meta tags, and in your template put a new variable where you want the description meta tags to be (or maybe copy the entire meta tag block from headinclude to your template and replace the variables as needed), then you have until the template eval to set that variable.