Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-27-2006, 06:12 AM
eJM's Avatar
eJM eJM is offline
 
Join Date: Sep 2004
Location: teh Ether
Posts: 121
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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>
Into this:
Code:
<td class="toptextadswrap">
<div align="right">
   <h1>Whatever the actual page title is</h1>
</div>
</td>
Using conditionals. I know the variables used for all the different pages, including:

$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
Reply With Quote
  #2  
Old 09-28-2006, 06:52 AM
eJM's Avatar
eJM eJM is offline
 
Join Date: Sep 2004
Location: teh Ether
Posts: 121
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I was really hoping someone could help me with this.
Reply With Quote
  #3  
Old 09-28-2006, 09:13 AM
Zoints Zoints is offline
 
Join Date: Feb 2004
Posts: 813
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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>
With:
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>
As you can see, the conditionals are only going to grow as you add more pages. There are some pages where you can't even do this, since the header template is parsed before the actual page title is set. (As for example the User Control Panel)

If your code is in the template 'navbar', then replace:
HTML Code:
<h1>$vboptions[bbtitle]</h1>
With:
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>
That will also work for the User Control Panel. However, adding conditionals for every template would be far too long to be sensible.


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:
preg_match("#<title>([^<]*)</title>#i"$output$matches);
$output str_replace('<!--HTML_PAGE_TITLE-->'$matches[1], $output); 
Plugin is Active: Yes

And then inside your template, replace:
HTML Code:
<h1>$vboptions[bbtitle]</h1>
With:
HTML Code:
<h1><!--HTML_PAGE_TITLE--></h1>
That will work for all pages, and even all custom mods (as long as they using the standard print_output() vbulletin function).

Hope that helps
Reply With Quote
  #4  
Old 09-28-2006, 04:18 PM
eJM's Avatar
eJM eJM is offline
 
Join Date: Sep 2004
Location: teh Ether
Posts: 121
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #5  
Old 09-28-2006, 07:49 PM
rogersnm rogersnm is offline
 
Join Date: Apr 2006
Location: Cyberspace, UK
Posts: 729
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well you have:
Quote:
define('THIS_SCRIPT', 'adv_index');
in the code so just use this for the conditional:
Quote:
<if condition="THIS_SCRIPT == 'showthread' OR THIS_SCRIPT == 'adv_index'">
Reply With Quote
  #6  
Old 09-28-2006, 08:08 PM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think Javascript would be well suited for this...

Something simple like:

Code:
<h1>&nbsp;</h1>
<script type="text/javascript">document.getElementsByTagName('h1')[0].innerHTML = document.title;</script>
seems to work quite well for me.

* unless of course you're doing this purely for SEO, in which case its useless
Reply With Quote
  #7  
Old 09-28-2006, 08:21 PM
eJM's Avatar
eJM eJM is offline
 
Join Date: Sep 2004
Location: teh Ether
Posts: 121
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
And of course, I also added another </if> at the end of the conditionals for every <if> I added to the list.

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
Reply With Quote
  #8  
Old 09-28-2006, 08:30 PM
Zoints Zoints is offline
 
Join Date: Feb 2004
Posts: 813
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #9  
Old 09-28-2006, 08:33 PM
eJM's Avatar
eJM eJM is offline
 
Join Date: Sep 2004
Location: teh Ether
Posts: 121
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by SirAdrian
I think Javascript would be well suited for this...

Something simple like:

Code:
<h1>&nbsp;</h1>
<script type="text/javascript">document.getElementsByTagName('h1')[0].innerHTML = document.title;</script>
seems to work quite well for me.

* unless of course you're doing this purely for SEO, in which case its useless
Hi SirAdrian,

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
Reply With Quote
  #10  
Old 09-28-2006, 08:43 PM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:09 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.08182 seconds
  • Memory Usage 2,285KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_code
  • (7)bbcode_html
  • (1)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete