View Single Post
  #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
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01236 seconds
  • Memory Usage 1,797KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (6)bbcode_html
  • (1)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete