PDA

View Full Version : Having issues with custom page titles using variables.


vbem2
08-11-2009, 05:33 AM
VB 3.7

In the custom template I have this: <title>$Year $MakeOther $ModelOther $Trim Gas Mileage ($vehiclenickname) - $vboptions[bbtitle]</title>

Works fine as a title for just viewing the page, but links show up like this: "Check it out: Gas Mileage () - EcoModder.com"

You can see it here in google: http://www.google.com/#hl=en&q=em-fuel-log.php&aq=f&oq=&aqi=&fp=pBEVNRsPIgM

Ideas?

Thanks!

Lynne
08-11-2009, 03:56 PM
It doesn't work fine when viewing the actual page either. This is in your source code:
<title> Gas Mileage () - EcoModder.com</title>

The variables you are using in the title are not availabe at the time the $header template is parsed. So, you need to change the location of the plugin where you define them if you want them to show up there.

vbem2
08-11-2009, 04:41 PM
Can you elaborate a little on that? I know php decently but find working with VB a little difficult. Is there a standard solution to this issue (I assumed it was common)?

Thanks!

--------------- Added 1250012958 at 1250012958 ---------------

Also, when I look at a page with firebug, I see this as the title tag: <title>1991 Honda CRX DX Gas Mileage (Vegan Powa!) - EcoModder.com</title>

*confused*

Sorry for being a newb

Lynne
08-11-2009, 04:56 PM
Perhaps your page is cached and that is why you see the whole title?

I don't know what your code is, but the variables you use in the <title> must be defined before they may be used. So, you need to define them before the header template is evaled which is in the global.php page (I am pretty sure). So, pick a plugin to use that gets evaled *before* the header template is evaled and define those variables in that plugin.

vbem2
08-11-2009, 05:18 PM
Yeah, I get that I need to define it first, I'm just a little confused as to the work flow. Also, I did a hard refresh to ensure I wasn't seeing a cached page, still shows the proper title for me though.

Anyway, here's my code.

First, this fetches the data: while ($row=$db->fetch_array($vehicledetails))
{
$vehiclenickname = $row[VehicleNickname];
$vehicleuserid = $row[UserID];
$Year = $row[Year];
$MakeOther = $row[MakeOther];
$ModelOther = $row[ModelOther];
$Trim = $row[Trim];
}

Then, further down in the php we have this which calls the template:

eval('print_output("' . fetch_template('emFuelLog') . '");');

Then in the template I have this: <head>
<meta name="description" content="$foruminfo[description]" />
<title>$Year $MakeOther $ModelOther $Trim Gas Mileage ($vehiclenickname) - $vboptions[bbtitle]</title>
$headinclude
</head>

A little unclear on why it's not getting through :(. Thanks for helping me!

--------------- Added 1250015630 at 1250015630 ---------------

O I see! It seems to be a problem with being logged in or not. Ideas?

--------------- Added 1250015872 at 1250015872 ---------------

Seems to be fixed now, let me know if you can see the titles!?

For some reason my partner had made the sql query that fetches those variables only display for the owner of the pages in question, oops!

Thank you so much for helping me figure it out :D

Lynne
08-11-2009, 05:51 PM
I see it now! Looks like you got the issue cleared up. :)

vbem2
08-12-2009, 01:23 AM
Sweet, thanks again for the help!