01502: Configurable <title> format in responsive skin

Summary: Configurable <title> format in responsive skin
Created: 2024-04-13 05:49
Status: Closed, added for 2.3.33.
Category: Feature
From: gnuzoo
Priority: 53
Version: 2.3.32

Description: Can you adjust the Responsive Skin so the HTML <title> element can be changed in config.php?
Currently every page is using :

<title>$WikiTitle | {$Group} / {$Title} $ActionTitle</title>

This should be the default, but it could be replaced with variable(s) that can be set in the
config file, for instance, I might not want to use a '/' or maybe not display the group name.


The PMWiki website says not to change a skin. It says to duplicate the skin and use the duplicate to
create your own new skin. If I modify the 'pmwiki-responsive' skin, then when I upgrade the skin,
my changes would be lost. If I create a new skin from it, then my new skin will not be upgraded
when the 'pmwiki-responsive' skin is upgraded. I have a PMWiki farm and websites might want to
have differing custom html title elements. I do not want to have to make a new skin for each website.

Using these variables in you config.php appears impossible:
$WikiTitle $Group $Title $ActionTitle

Is it too much to ask for a way to set the html <title> element in a config.php file?

I often change the format of the title in my custom skins. With your suggestion, the PmWiki philosophy #5 "Be easy to install, configure, and maintain", the "configure and maintain" parts will be improved. On the other hand, Pm has told me he wants the core skins to be relatively simple so that people without much HTML, PHP, and PmWiki knowledge can quickly understand the skin template and adapt it for their needs. So I want to figure out how to implement this, keeping both goals. Let me think about it. --Petko

I would be happy if setting a custom html title element was a recipe in the cookbook. That might
provide easier way to do more complex coding, yet just make a few adjustments in the config.php file. -gnuzoo

Added $HTMLTitleFmt for 2.3.33, set in config.php:
$HTMLTitleFmt = '$Title | $WikiTitle $ActionTitle';

Before 2.3.33, you also need such a function:
function MyFmtHTMLTitle($pagename) {
  global $HTMLTitleFmt, $TmplFmt;
  $start = &$TmplFmt['Start'][1];
  $start = preg_replace('!(<title>).*?(</title>)!si', "$1{$HTMLTitleFmt}$2", $start, 1);
$PostConfig['MyFmtHTMLTitle'] = 1000;


Curiously, Pm has removed the same variable 20 years ago, see PITS:00093, ChangesFromPmWiki1 and Mailing list announcement, arguing that it is better for this to be defined in the skin template. Some skins still use this variable (Triad, Gemini, FixFlow). I didn't remember this variable, it just felt natural to name it this way. I wonder why it didn't stay editable in config.php. --Petko

I wrote to Pm to ask if he sees any downsides, and if he does and if they are worse than the φ #5 "configure and maintain" parts above, we may revert it. In such a case you would add the function. --Petko

> Curiously, Pm has removed the same variable 20 years ago
I have only used PMWiki for 19 years. IMHO, Pm was wrong to do this. I prefer fewer & easier to customize. --gnuzoo

If nobody needed this for 20 years, Pm was arguably right to remove it. :-) He said it was okay to re-add it. --Petko

I am more than happy to debate this forever. A lot of users may want this but would not bother going through the hassle
of trying to get it. It loses importance when you work full time. I have been wanting this feature a long time and did
not have time and priority to follow up on it like I do now. I tend to pay attention to details and want control of the
computer/application/whatever and not the other way around. Pm is not a god and does not know everything.
I say Pm was arguably wrong to remove it. Perhaps he did not have time/priority to do it right. The html title
element is required in every html document on the internet. Users should be able to set it however they please. --gnuzoo

I see your point. --Petko

Been trying this. The "$ActionTitle" inserts ' | ' before showing the action. I might want to use some other text, like maybe ' :'. Can you please adjust this? --gnuzoo

This is already possible, see $ActionTitleFmt. --Petko

Found I can use "$action" instead of "$ActionTitle". Much easier to use IMHO.
Also found I can use '$Group', as in $HTMLTitleFmt = '$Group:$Title' if I do not want the website name. Thanks! --gnuzoo

Well $ActionTitleFmt doesn't show "browse" or another action, if it is not defined as a key. I prefer not to have "browse". :-) --Petko

100% agree! - Got that before u wrote it.
$HTMLTitleFmt = $action=='browse' ? '$WikiTitle - $Title' : $action.':$WikiTitle - $Title' ;