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 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 file (which is used by any skin that doesn’t supply its own 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 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\ 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.

2 thoughts on “Solved: Override Default HTML Title in b2Evolution 2.x”

  1. When you meet with your pool contractor below are a few specifics to talk about with her or him as they relate
    to your renovation project:Do the tiles need to be removed, replaced, upgraded.
    However, as much as we want to imagine this,
    and generally have every reason for this, the fact isn’t quite so clear-cut.
    It’s a functional gadget for removing small sticks and
    insects; many models are integrated within the pool
    system while others are manually operated.

  2. 除湿机的除湿原理是风扇将潮湿空气抽入机内,温度相对较高的潮湿空气接触温度相对较低的蒸发器,此时空气中的水份冷凝成小水珠,滞留&#22

Leave a Reply

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