UBB.Dev
Posted By: FredR meta title - 09/23/2002 6:49 PM
Hello All

ubbthreads sent me over here -- so here I am :-)

Is it possible to insert the thread subject as the meta title tag? While at it, how about the first 140 characters of the text as the meta description?

In our case, this would highly beneficial for our Google ranking in particular.

Thanks. Fred
Posted By: AllenAyres Re: meta title - 09/23/2002 7:35 PM
Agreed... if I see how, I'll report back

And welcome
Posted By: JustDave Re: meta title - 09/23/2002 8:07 PM
Ok, let me see if I can explain this correctly... lol



Go to your Admin area and chose to edit your configure file.

At the very bottom of the configure screen you should see a text area just below this line "The following variables are unknown to the base UBB.threads package, but might be used by installed hacks or modifications to the program:"

In that text box create a variable like so:

$config['meta_tags'] = "";




Ok now in your ubbt_header.tmpl file, located in your ubbthreads/templates/default directory just after the <head> tag add this:

{$config['meta_tags']}

and remove this:

<title>$inputTitle - {$ubbt_lang['POWERED_BY']} UBB.threads™</title>




Ok, now in your showflat.php file find this:
code:

$query = "
SELECT B_Replies,B_Counter,B_Last_Post,B_Subject,B_Rating,B_Rates,B_RealRating
FROM {$config['tbprefix']}Posts
WHERE B_Number = $current
";
$sth = $dbh -> do_query($query);
list($checkreplies,$count,$posted,$tsubject,$Rating,$Rates,$stars) = $dbh -> fetch_array($sth);



and change it to this:

code:

$query = "
SELECT B_Replies,B_Counter,B_Last_Post,B_Subject,B_Rating,B_Rates,B_RealRating,B_Body
FROM {$config['tbprefix']}Posts
WHERE B_Number = $current
";
$sth = $dbh -> do_query($query);
list($checkreplies,$count,$posted,$tsubject,$Rating,$Rates,$stars,$Body) = $dbh -> fetch_array($sth);
$metaKeywords = $tsubject;
$metaDescription = substr($Body,0,139);
$config['meta_tags'] = "<title>$tsubject</title>";
$config['meta_tags'] .= "<meta name="keywords" content="$metaKeywords" />";
$config['meta_tags'] .= "<meta name="description" content="$metaDescription" />";






In your showthreaded.php script find this:

code:

$query = "
SELECT B_Main, B_Last_Post,B_Subject,B_Rating,B_Rates,B_RealRating
FROM {$config['tbprefix']}Posts
WHERE B_Number = $Number
AND B_Board = '$Board'
";
$sth = $dbh -> do_query($query);
list ($current,$posted,$tsubject,$Rating,$Rates,$stars) = $dbh -> fetch_array($sth);
$dbh -> finish_sth($sth);



and change it to this:

code:

$query = "
SELECT B_Main, B_Last_Post,B_Subject,B_Rating,B_Rates,B_RealRating,B_Body
FROM {$config['tbprefix']}Posts
WHERE B_Number = $Number
AND B_Board = '$Board'
";
$sth = $dbh -> do_query($query);
list ($current,$posted,$tsubject,$Rating,$Rates,$stars,$Body) = $dbh -> fetch_array($sth);
$metaKeywords = $tsubject;
$metaDescription = substr($Body,0,139);
$config['meta_tags'] = "<title>$tsubject</title>";
$config['meta_tags'] .= "<meta name="keywords" content="$metaKeywords" />";
$config['meta_tags'] .= "<meta name="description" content="$metaDescription" />";





Hope this helps.


I left the meta keywords in because not all search engines are powered by google.
Posted By: Aglavalin Re: meta title - 09/23/2002 8:08 PM
Will search engines still pick up the META tags if they are in the body, and not in the head of the webpage? If so, then it would be fairly easy and probably not require any more queries on the showflat.php page. If an extra query has to be done for the header, then it would slow down a large or busy board.
Posted By: JustDave Re: meta title - 09/23/2002 8:24 PM
The modification I posted makes no extra queries.



Edit Note: Forgot to mention that placing the meta tags in the body would probably be a big no no for XHTML validation.
Posted By: FredR Re: meta title - 09/25/2002 3:45 PM
Thanks Dave

Not really but it’s a good start - looks straight forward. Give me hint on changing the $metaKeywords to lower case.

As to the <title></title> tag (that's what I meant), it is the single most important factor, followed by the description. They keywords don't weight much because of abuse. I've got hundreds of #1 listings to back that up. Look up chef forums, chef discussions, chef community, chef guide at google…

The title tag now displays the header-insert from the admin panel. That contains the phrase “Chef Guide Community Forums” which I can add to the metaKeywords and metaDescription easy enough to at least retain top billing with my main theme.

Here’s the kicker. If the thread subject is on “canning vegetables”, that now appears in the description and keywords, it won’t get you past page 3 of the search engine output. (no one will find it). Would it also appear in the <title></title>, with a good page ranking and a text body that speaks about canning vegetables, you’re top ten.

So the exercise really won’t yield much, other than some stray hits. So I think it is very important for the success of forum operators to address this issue in future releases so we don’t have to violate copyrights.

Fred Roosli
Chef2Chef.Net

Posted By: JustDave Re: meta title - 09/25/2002 3:53 PM
As it stands, the thread being viewed has the subject appended to the page's title. Perhaps what ever variable that is being used to do this can be modified without stepping on license issues. The whole title thing has been a questioned many times before by others. I honestly don't know how else to handle anything dealing with the title other than "don't touch" after reading the licensing agreement.
Posted By: JoshPet Re: meta title - 09/25/2002 4:27 PM
Straight from Rosemary.....

The "Powered by UBBThreads" in the TITLE (not at the bottom) may be edited or removed. They are only concerned with the notice at the bottom.

Josh
Posted By: JustDave Re: meta title - 09/25/2002 4:30 PM
Thanks Josh

I'll edit my instructions above to include modifying the title on the fly accordingly
Posted By: FredR Re: meta title - 09/25/2002 4:37 PM
Boy, I just had to look at the source...thought I missed something.

My board does not append the subject of the thread

<title>Chef Guide for Chefs: Community Forums at Chef2Chef.Info</title>

If that were the case, problem solved...
Posted By: JustDave Re: meta title - 09/25/2002 4:41 PM
I just edited my instructions. Let me know how it goes.
Posted By: JoshPet Re: meta title - 09/25/2002 4:58 PM
That's always been a confusing issue if we can touch that....
Someone asked at community....and I PMed her and asked her to ask for sure.

Here is the official word.
Posted By: Dave_L_dup1 Re: meta title - 09/25/2002 7:04 PM
Just in case that post gets lost

Sorry, glad you asked about that detail! You CAN remove the powered by wording that appears in the browser title. You cannot remove the powered by wording that appears on the forum pages.

Rosemary O'Neill Sep 17, 02 18:20
Posted By: FredR Re: meta title - 09/25/2002 8:40 PM
Smart idea
Posted By: FredR Re: meta title - 09/25/2002 8:46 PM
Thanks Dave

The revised code looks simply mavellous!

Fred
Posted By: FredR Re: meta title - 09/27/2002 1:28 PM
Dave

I got throught the first two steps just fine. After the third step, the showflat.php, I received this error message:

SQL ERROR: Unable to do_query: SELECT B_Replies,B_Counter,B_Last_Post,B_Subject,B_Rating,B_Rates,B_RealRating FROM Posts WHERE B_Number = 10274
Table 'forum.Posts' doesn't exist
Warning: Supplied argument is not a valid MySQL result resource in [removed some info here ] /htdocs/ubbthreads/mysql.inc.php on line 83

What might that be? I am running 6.0.3, different table name?

Fred
Posted By: Dave_L_dup1 Re: meta title - 09/27/2002 2:55 PM
$config['tbprefix'] was added in 6.1.

For 6.0.3, you'll either need to add $config['tbprefix'] = "w3t_"; to the config file, or in the query, replace {$config['tbprefix']}Posts with w3t_Posts.
Posted By: JustDave Re: meta title - 09/27/2002 3:19 PM
Dave_L is correct. I only have 6.1 sitting in front of me so anything I do is based off of that. Sorry about that

If you follow Dave's instruction that should fix the problem.

Posted By: FredR Re: meta title - 09/28/2002 12:48 AM
No problem and no need looking like this

You've been a great help. So what's another few ounces of midnight oil...

Fred
Posted By: FredR Re: meta title - 10/18/2002 11:44 AM
Hi Dave

I finally got around to give this a twirl. Yes it worked with the w3t_Posts change.

A couple of issues that I ran into:

1. The description of course picks up all kinds of html code, line breaks, images, etc. if they are in the first 140 characters.

My fix was to replace the description with the title followed by a generic blurp.

2. The header-insert function (in the admin panel) replaces the changes in showflat.php and showthreaded.php

I looked for a way to prevent the showflat.php and showthreaded.php ONLY from using the header-insert but that got a bit to complex for a newbie.

Any ideas?
Posted By: FredR Re: meta title - 10/19/2002 7:57 PM
Hi Dave

I had to remove the shwoflat.php modification. There's a glitch.

A link pointing to a multi-page thread from the past 24-hour view would not show the amount of pages or the post. You had to get there through the Main Index...

Fred
Posted By: Dave_L_dup1 Re: meta title - 10/19/2002 9:44 PM
I'm assuming these issues are addressed to JustDave, not me.
Posted By: JustDave Re: meta title - 10/20/2002 12:44 AM
I'm not sure what this modification would have in common with the "view messages - 24 hours, 48 hours and 7 days" so I am not sure what the problem could have been. This mod doesn't affect the posts in any way actually. It simply adds some meta tags to the <head>...



Edit note: after thinking about it perhaps it was some HTML in the meta tag that was causing the problems. You would probably need to remove html formatting before inserting anything into the tags.
Posted By: sportbikes Re: meta title - 11/10/2002 1:35 AM
Similar problem about the multi pages not showing up?

I don't allow HTML on the board, just UBB code. I'm thinking that the descrip and keywords are being developed on the fly? I have added the code as defined in this thread to my 6.1.1 UBB Threads.

Any ideas?

Posted By: JustDave Re: meta title - 11/10/2002 1:46 AM
Perhaps it's HTML showing up in the meta tags that is throwing things off. I'll try installing this on my test site and see if I can find what is actually going wrong.
Posted By: sportbikes Re: meta title - 11/11/2002 6:08 AM
There was a line in the original Showfalt.php file that seems to have been overlooked. At first I deleted it with the the rest of that section. Then I left it in. No luck either way.

What follows is from the original portion of the Showflat file:
$query = "
SELECT B_Replies,B_Counter,B_Last_Post,B_Subject,B_Rating,B_Rates,B_RealRating
FROM {$config['tbprefix']}Posts
WHERE B_Number = '$current'
";
$sth = $dbh -> do_query($query);
list($checkreplies,$count,$posted,$tsubject,$Rating,$Rates,$stars) = $dbh -> fetch_array($sth);
$length = $checkreplies + 1;

Note the last line. This last line was not mentioned in the instructions for this hack. I'm not sure if it was an oversite or not, but I thought I'de bring it to your attention.
© UBB.Developers