Title format on startpage vs other pages

Discussions and requests related to new CMSimple features, plugins, templates etc. and how to develop.
Please don't ask for support at this forums!
svasti
Posts: 1651
Joined: Wed Dec 17, 2008 5:08 pm

Title format on startpage vs other pages

Post by svasti » Fri Oct 24, 2014 12:26 pm

SUMMARY of thread: One could give the startpage an individual title through the title entry in meta_tags pagedata. However this doesn't work as expected. In svasti's view it's a bug and he proposes a one line fix.
The opinions of other developers are invited.
----------------------------------------------------------------------------------

Hi all,
I suggest that we add the config variable
$cf['title']['startpage']="{SITE}";

so that the title (in the browser tab) on the 1st page (=startpage or homepage) can be set different from the title of other pages. Thus the startpage can have the title "MYSITE" and the other pages can get "MYSITE – HEADLINE".

Now I find that Google usually lists XH pages as "MYSITE – Start" or "MYSITE – Welcome", which looks rather odd compared to the way other websites are listed.

The requested change is quite simple, in functions.php starting with line 2084 the changes are

Code: Select all

function XH_title($site, $subtitle)
{
    global $cf,$s;

    if ($site != '') {
        $site = XH_hsc($site);
        $replacePairs = array('{SITE}' => $site, '{PAGE}' => $subtitle);
        $title = $s == 0
            ? strtr($cf['title']['startpage'], $replacePairs)
            : strtr($cf['title']['format'], $replacePairs);
    } else {
        $title = $subtitle;
    }
    return $title;
}
 
plus an additional $mtx['startpage']="Startseite"; in metade.php
Last edited by svasti on Sat Jan 17, 2015 6:59 pm, edited 1 time in total.

manu
Posts: 1086
Joined: Wed Jun 04, 2008 12:05 pm
Location: St. Gallen - Schweiz
Contact:

Re: Title format on startpage vs other pages

Post by manu » Fri Oct 24, 2014 1:45 pm

plus $tx['help']['title_startpage']=" ... "; in all according language files..

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Title format on startpage vs other pages

Post by cmb » Fri Oct 24, 2014 5:08 pm

I'm wondering, if we really need another config option here. Maybe even $cf['title']['format'] has been overkill. :?
Christoph M. Becker – Plugins for CMSimple_XH

svasti
Posts: 1651
Joined: Wed Dec 17, 2008 5:08 pm

Re: Title format on startpage vs other pages

Post by svasti » Fri Oct 24, 2014 9:18 pm

It may be true that
cmb wrote:$cf['title']['format'] has been overkill. :?
, however it is easy to understand and gives a nice control... and the extra control over the startpage makes it even better. Some other new variables a much more difficult to grasp.

Too bad, systems have the tendency to become more and more complex... CMSimple being no exception

Alternatively I'd propose to delete $cf['title']['format'] and make

Code: Select all

function XH_title($site, $subtitle)
{
    global $cf,$s;

    if ($site != '') {
        $site = XH_hsc($site);
        $title = $s == 0
            ? $site
            : $site . ' – ' . $subtitle;
    } else {
        $title = $subtitle;
    }
    return $title;
} 
We could vote in the roadmap:
  • (a) no change,
  • (b) add $cf['title']['startpage'],
  • (c) delete $cf['title']['format']

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Title format on startpage vs other pages

Post by cmb » Sat Oct 25, 2014 10:30 am

JFTR: the discussion in the related German thread is going on. We should consider the ideas and arguments there, too.
Christoph M. Becker – Plugins for CMSimple_XH

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Title format on startpage vs other pages

Post by cmb » Thu Dec 18, 2014 11:31 pm

svasti wrote:We could vote in the roadmap:
(a) no change,
(b) add $cf['title']['startpage'],
(c) delete $cf['title']['format']
To be honest, I don't like either solution. (c) is a no go, unless we decide to switch to a more customary format (it's often recommended to go from specific to general in the title, because in most modern browsers the titles are displayed in small tabs). (b) would mean just another config option for a very narrow use case (it wouldn't cater for hidden intro pages, for instance). Leaving it as it is, seems to be just the lesser evil. For now I can't think of something better, so I voted "later" for both options.
Christoph M. Becker – Plugins for CMSimple_XH

svasti
Posts: 1651
Joined: Wed Dec 17, 2008 5:08 pm

Re: Title format on startpage vs other pages

Post by svasti » Thu Jan 15, 2015 7:18 pm

As this proposal didn't make it I'll change the proposal a bit:

What about an extra field in pagedata tab meta for the pagetitle (in case you want it differnt from the config default). This would be a fitting place, one gets the full flexibility and the config doesn't become bigger. Only the pagedata grows, which may be of some concern. There could be a plugin config field to disable unused metadata fields in the pagedata.

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Title format on startpage vs other pages

Post by cmb » Fri Jan 16, 2015 3:35 pm

svasti wrote:What about an extra field in pagedata tab meta for the pagetitle (in case you want it differnt from the config default). This would be a fitting place, one gets the full flexibility and the config doesn't become bigger.
An interesting idea. Are you interested in working out a patch?
svasti wrote:Only the pagedata grows, which may be of some concern.
I'm not overly concerned with that. Depending on the length of the field name an empty field would use 20-30 bytes per page, so for 100 pages, 2-3KB total -- that seems pretty innocuous nowadays.
Christoph M. Becker – Plugins for CMSimple_XH

svasti
Posts: 1651
Joined: Wed Dec 17, 2008 5:08 pm

Re: Title format on startpage vs other pages

Post by svasti » Fri Jan 16, 2015 6:11 pm

I had a look at it. Actually we have the meta-tag title first in the meta pagedata tab, with the nice help tooltip:
<p>A good title might improve the search engine ranking.</p>
However, an entry here, lets say "xxx" results in something unexpected in the browser: "xxx – Welcome to CMSimple_XH"
So the $cf['title']['format']="{SITE} &ndash; {PAGE}" will still give out the page headline and only [SITE] is changed.

I'd consider that a bug. If there is an title entry in the pagedata, $cf['title']['format'] should be overwritten.

The solution is simple:
add

Code: Select all

$cf['title']['format']="{SITE}"; 
after line 55 in plugins/meta_tags/index.php so that the relevant code becomes:

Code: Select all

/*
 * Set the meta tags contents.
 */
if ($pd_current['title']) {
    $cf['site']['title'] = $pd_current['title'];
    $cf['title']['format']="{SITE}";
}
As the change is so small and it's a bug in my view and there was a request "Add config var $cf['title']['startpage']", I think all this will be solved with this one little line and we could handle it as a bug and incorporate it still into 1.6.5

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Title format on startpage vs other pages

Post by cmb » Sat Jan 17, 2015 12:13 am

svasti wrote:As the change is so small and it's a bug in my view and there was a request "Add config var $cf['title']['startpage']", I think all this will be solved with this one little line and we could handle it as a bug and incorporate it still into 1.6.5
I tend to agree that this is a bug and that your patch would fix it nicely, but it seems to me that requires thorough investigation; otherwise we might break intended behavior. Actually, I don't think that the current behavior is intended, but it seems that is there since early XH versions, and somehow I can't imagine that nobody ever had noticed and reported it. To be honest, I have noticed it before, but without further consideration I regarded it as intended. :?
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply