Solved: Override Default HTML Title in b2Evolution 2.x

I’d set up my 1.x installation of b2Evolution to use a custom HTML title in the format:

<title>[Post/Page name – ] Blog name</title>

On installing 2.4, however, I noticed that the default title is just the post/page name if it exists and the blog name if it doesn’t (i.e. for the posts list). This was based on a function call to a function called request_title. Google didn’t tell me much about this function (not the 2.x version anyway) so I went hunting and found the function in the file: \inc\_core\_template.funcs.php

It’s one of the new 2.x style functions that takes a single associative array as its parameter instead of taking a list of

parameters in a specific order. From the definition the parameters it can take are:

  • auto_pilot – default: ‘none’. If this is set to ‘seo_title’ (which it is in any skins that don’t override the default _html_header.inc.php) default values override some of the parameters (see below).
  • title_before – default: ”.
  • title_after – default: ”.
  • title_none – default: ”.
  • title_single_disp – default: true.
  • title_single_before – default: ‘#’.
  • title_single_after – default: ‘#’.
  • title_page_disp – default: true.
  • title_page_before – default: ‘#’.
  • title_page_after – default: ‘#’.
  • glue – default: ‘ – ‘.
  • format – default: ‘htmlbody’.
  • arcdir_text – default: T_(‘Archive directory’).
  • catdir_text – default: T_(‘Category directory’)

The ‘autopilot’ parameter is set to ‘seo_default’ by the default _html_header.inc.php file (which is used by any skin that doesn’t supply its own _html_header.inc.php file). This has the effect of overriding the values of the following parameters:

  • format = ‘htmlhead’
  • title_after = $params[‘glue’].$Blog->get(‘name’)
  • title_single_after = ”
  • title_page_after = ”
  • title_none = $Blog->dget(‘name’,’htmlhead’)

It looks to me like to truly customise the HTML title tag value you need to delete the line:

'auto_pilot' => 'seo_title',

from the _html_header.inc.php or create a copy of this file in your specific skin’s directory and delete that line from the copy (if you put this file in your skin’s own directory, your skin should use this ‘custom’ version instead of the backup in the ‘skins’ directory). I took the latter option and created a copy of \skins\_html_header.inc.php in the subdirectory for my skin. To get the effect described above (i.e. <title>[Page/post name - ]Blog name</title>), I amended the PHP code between the title tags to the following:

request_title( array(
'format' => 'htmlhead',
'title_after' => ' - ' . $Blog->dget('name','htmlhead'),
'title_none' => $Blog->dget('name','htmlhead'),
) );

I also added two more elements to the array to change the headings when looking at the archives and categories from “Archive directory” and “Category directory” to “Archives” and “Categories”. This was fairly simple – just adding:


'arcdir_text' => T_('Archives'),
'catdir_text' => T_('List of Categories'),

Author: nerd.

An experienced IT professional, I used to run a number of small websites and spend a lot of time tinkering with my sites or my PC - back when I had free time.

Leave a Reply

Your email address will not be published. Required fields are marked *