The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
How do I use conditional in the $header to show page title next to logo?
I'm trying to turn this:
Code:
<td class="toptextadswrap"> <div align="right"> <h1>$vboptions[bbtitle]</h1> </div> </td> Code:
<td class="toptextadswrap"> <div align="right"> <h1>Whatever the actual page title is</h1> </div> </td> $pagetitle $foruminfo[title_clean] $thread[title] $threadinfo[title] Among several others. I just don't know how to write the conditionals to make the various page titles appear in the upper right corner of my web pages instead of the standard $vboptions[bbtitle]. Any help would be appreciated. Jim |
#2
|
||||
|
||||
I was really hoping someone could help me with this.
|
#3
|
|||
|
|||
Hi Jim,
I hope you have been well There are two ways to go about it, the first way is just using template conditionals and only using the page title for certain major areas, such as showthread.php and forumdisplay.php. The drawback would be that some pages, such as reporting bad posts, retrieving lost passwords, editing polls, etc are overlooked, as conditionaling them would make the statement very lengthy (since there are over 40 different page titles). The second one would be a 1:1 match of the actual page title, at the cost of a little processing power. It's a plugin that parses the the html output during print_output() for the actual content of the <title> tag. The first way: If your code is in the template 'header', then replace: HTML Code:
<h1>$vboptions[bbtitle]</h1> HTML Code:
<h1> <if condition="THIS_SCRIPT == 'showthread'"> $threadinfo[title]<if condition="$pagenumber>1"> - <phrase 1="$pagenumber">$vbphrase[page_x]</phrase></if> - $vboptions[bbtitle] <else /> <if condition="THIS_SCRIPT == 'forumdisplay'"> $foruminfo[title_clean]<if condition="$pagenumber>1"> - <phrase 1="$pagenumber">$vbphrase[page_x]</phrase></if> - $vboptions[bbtitle] <else /> <phrase 1="$vboptions[bbtitle]">$vbphrase[x_powered_by_vbulletin]</phrase> </if> </if> </h1> If your code is in the template 'navbar', then replace: HTML Code:
<h1>$vboptions[bbtitle]</h1> HTML Code:
<h1> <if condition="THIS_SCRIPT == 'showthread'"> $threadinfo[title]<if condition="$pagenumber>1"> - <phrase 1="$pagenumber">$vbphrase[page_x]</phrase></if> - $vboptions[bbtitle] <else /> <if condition="THIS_SCRIPT == 'forumdisplay'"> $foruminfo[title_clean]<if condition="$pagenumber>1"> - <phrase 1="$pagenumber">$vbphrase[page_x]</phrase></if> - $vboptions[bbtitle] <else /> <if condition="$pagetitle"> $vboptions[bbtitle] - $pagetitle <else /> <phrase 1="$vboptions[bbtitle]">$vbphrase[x_powered_by_vbulletin]</phrase> </if> </if> </if> </h1> The second way: Add the following plugin: Product: vBulletin Hook Location: global_complete Title: Displaying the page title inside templates Execution Order: 5 Plugin PHP Code: PHP Code:
And then inside your template, replace: HTML Code:
<h1>$vboptions[bbtitle]</h1> HTML Code:
<h1><!--HTML_PAGE_TITLE--></h1> Hope that helps |
#4
|
||||
|
||||
Yes, David, that is very helpful indeed. Thank you. I hope that I can press you a bit more to further refine this.
My main reason for this is purely selfish: I want every possible advantage to rank higher with all search engines (relevant to my particular niche forum). Ideally, every page of importance to search engines should have this replacement page title (for the novice reader: not to be confused with the document title, which is expressed between the <title> tags of the HTML document). Pages that search spiders are barred from via robots.txt, or that will gain nothing of value from a more specific <h1> tag, I am not concerned with and the standard $vboptions[bbtitle] is just fine on those pages. I customized your code a little so that is was not an exact copy of the document title. I don't feel it is necessary to include $vboptions[bbtitle] on all the page titles, in my situation, so I removed that part of your code. It works nicely and your first option works quite well with the example code you provided. No doubt this alone can improve anyone's board, not only with SEO, but also in the ability of the visitor to see at a glance just where they are on the site -- as long as they are in the confines of the forum. My problem now is that I would like this to work in all my vBadvanced pages as well. I use vBadvanced to build static pages throughout my site (www.thefloorpro.com). Your code leaves all of those pages with only the $vboptions[bbtitle] title. Except for the home page, all of the pages have their own title. I tried variations, but have had no luck convincing the document to display the title as it should. Perhaps you can help a little more to bring this about. The information I have relied on to write the code (and failed) in in the original cmps_index.php is as follows: define('THIS_SCRIPT', 'adv_index'); define('VBA_PORTAL', true); define('VBA_PAGE', 'index'); define('VBA_SCRIPT', 'CMPS'); require_once('./includes/vba_cmps_include_template.php'); The only variable is the line that includes "'VBA_PAGE', 'index'", where I change "index" to the Page Identifier indicated in the vBa CP (eg: articles_index, about, tile_over_vinyl_flooring, etc.). I would prefer to use template conditionals because it requires less processing power and it appears it can meet my selfish needs very well. To be honest, I haven't tried your second method, although I am sure it will work too. But then I don't think it would display the title without the inclusion of $vboptions[bbtitle], which is important for the document title, but not the page title (H1 tags). My humble gratitude for any additional help. Thank you very much for your assistance with this. I believe it can help a great many people who are interested in improving their board's SEO and semantic use of code. This is one more example of how the header tags can be put to valuable use on the vBulletin forum. I will be sure to relay your solutions to the other couple of forums I have sought help with this in. Best R'gards, Jim |
#5
|
|||
|
|||
Well you have:
Quote:
Quote:
|
#6
|
||||
|
||||
I think Javascript would be well suited for this...
Something simple like: Code:
<h1> </h1> <script type="text/javascript">document.getElementsByTagName('h1')[0].innerHTML = document.title;</script> * unless of course you're doing this purely for SEO, in which case its useless |
#7
|
||||
|
||||
Hello Roger,
Thanks for your reply. Unfortunately that didn't work. I suspect that the reason is because the original results of the conditional is $threadinfo[title] and there is no such information in adv_index. When I tried to do this before I left my previous message, I used the following conditionals separately and none of them worked (I added these lines to the conditionals supplied by Mr. Chapman): HTML Code:
<else /> <if condition="THIS_SCRIPT == 'adv_index'"> $VBA_PAGE ---------------------------------------------- <else /> <if condition="THIS_SCRIPT == 'adv_index'"> $adv_portal ---------------------------------------------- <else /> <if condition="THIS_SCRIPT == 'adv_index'"> $pagetitle ---------------------------------------------- <else /> <if condition="THIS_SCRIPT == 'adv_portal"> $pagetitle None of those worked, like I said. I thought at least one of them might. Maybe the answer is part of one and part of another. There are a lot of possibilities I guess, but only one right answer. Thanks again for trying to help. Jim |
#8
|
|||
|
|||
Jim,
Just a quick update. I'm sure we can get that working as desired. However, my schedule today is rather hectic. I'll try to get something to you by late this evening. My apologies for the delay. In the meantime, give my second method a shot. I think you might be pleasantly surprised and the additional processing isn't that bad. I'd install it on my forum and i'm very anal about such things. |
#9
|
||||
|
||||
Quote:
I'm not sure I understand why that would be useless for SEO. Is it because there is actually nothing between the H1 tags? In that case, you're right. For me it's not strictly SEO, but it is mostly SEO. I definitely want the value of using header tags throughout my site and want the page title to be H1. But I also want to reiterate that the document title has the $vboptions[bbtitle] as well as the page title, which I feel is redundant and too lengthy for my purposes of a H1 page title. I appreciate your input though and I wouldn't doubt your suggestion could be just the solution someone else is looking for at some time. My hope is that this discussion will become one of the stopping points for many future searches for the issues we are bringing up. Good stuff here. Jim |
#10
|
||||
|
||||
It's useless for SEO because most bots don't have javascript enabled... But it is less server load. If I had to choose, I would use this for members, and use the regex way for guests. It's far less processing, though a regex isn't too bad.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|