Topic Closed
13 Posts

We would like to alter the TITLE tag (as displayed in the browser's tab or title bar). The options seem to be:

1. The worst solution would be to manually modify the function GetHead_TKD() at Line 2053 in "include/tool/gpOutput.php". Here, one can easily change the separator from ' - ' to ' | ', swap the order of $config['title'] with the page title, or omit the $config['title'] entirely. However, any changes here must be re-applied when Typesetter is upgraded, which causes maintenance issues. We would prefer to avoid this.

2. Another possible solution may be to create a plugin which hooks to gpOutput::GetHead that would allow the TITLE tag to be overridden. Is this possible? Which variable would the plugin need to modify in order to intercept and alter the TITLE before it is rendered?

3. Another possible solution may be to provide a core configuration setting that could be used to construct the TITLE. For example, if(isset($config['customtitle'])), then a TITLE template could be used within GetHead_TKD() to construct the string, e.g. "SITE_TITLE | PAGE_TITLE", with the variables replaced accordingly.

4. Finally, our preference is that this could be done within the template. However, this seems to be impossible with a call to ob_start() before gpOutput::GetHead inside the template, because it appears to only insert a placeholder where the actual HEAD content will later appear. In other words, the actual HEAD data does not seem to be accessible from within the template for modification.

Changing the title style is a pretty trivial change, but the concern is that any modifications to the code will be lost upon upgrading. Any ideas?

Edited: 6 years ago#9564

263 Posts
1 Themes
8 Plugins

Rewriting the html output just before it is sent to the browser is possible by calling ob_start with a callback function from a WhichPage hook.

6 years ago#9566

1.5K Posts
16 Plugins

This would be a modified MetaTitle function (/include/tool/Output.php, from line 1321) that calls a new plugin filter hook "MetaTitle"

 * Add the <title> tag to the page
 * return the value
public static function MetaTitle(){
  global $page, $config;

  $meta_title = '';
  $page_title = '';
  if( !empty($page->TitleInfo['browser_title']) ){
    $page_title = $page->TitleInfo['browser_title'];
  }elseif( !empty($page->label) ){
    $page_title = strip_tags($page->label);
  }elseif( isset($page->title) ){
    $page_title = \gp\tool::GetBrowserTitle($page->title);
  $meta_title .= $page_title;
  if( !empty($page_title) && !empty($config['title']) ){
    $meta_title .=  ' - ';
  $meta_title .= $config['title'];

  $meta_title = \gp\tool\Plugins::Filter('MetaTitle', array($meta_title) );
  // msg("MetaTitle after Plugin Filter: " . pre($meta_title));

  echo "\n" . '<title>' . $meta_title . '</title>';
  return $page_title;

With this new filter, a plugin or a theme will be able to modify the browser title.

Replace the function and see/install this small proof-of-concept plugin…

get Custom Page Title 1.0


Unpack the ZIP into your /addons directory and install it via
Admin Toolbox → Plugins → Manage → Available → Install


edit: I made a pull request on github. If Josh is willing to add the new hook, CMS updates will be safe.

Edited: 6 years ago#9568

13 Posts
Wow, this is a perfect solution. Thanks for your response. Hopefully the pull request gets merged to prevent title changes from reverting in the future!
6 years ago#9569

Topic Closed



elFinder 2.1.50 in Upcoming Release

A new release for Typesetter is in the works with a lot of improvements including the ... Read More

Typesetter 5.1

Typesetter 5.1 is now available for download. 5.1 includes bug fixes, UI/UX improvements, ... Read More

More News

creisi productions

Dienstleistungen von creisi productions, Ennetb├╝rgen (Schweiz): * Konzeption, Planung und Erstellung Ihres Internet-Auftritts * Betreuung und Aktualisierung/Pflege Ihrer Websi...

Find out more about our Provider Spotlight

Log In