?
avatar smehrbrodt
smehrbrodt
20 Jul 2016

The JDocument::setTitle method should respect the setting whether to show the page name in the title.

Currently each caller of that method needs to explicitly check that setting and add the page name to the title if necessary. This should be handled by the setTitle method instead.

For b/c we maybe need to introduce a new method instead of changing the existing one. Or introduce a parameter with a default value.

avatar smehrbrodt smehrbrodt - open - 20 Jul 2016
avatar mbabker
mbabker - comment - 20 Jul 2016

I disagree. For developer convenience it might be a "better" behavior to do so but considering this can be influenced by parameters, putting that logic directly into JDocument creates more deep rooted internal couplings. Generally setter methods shouldn't do much more beyond validate a value it is given is valid and store it to memory, adding more data to what's you've requested be set creates inconsistent behavior (if I tell it to set "Test" as the title and immediately call the get method and get "Test | Site" as the value I'm going to think something overwrote my value).

A helper method somewhere to deal with the duplicated logic might not be so bad so long as no component has a parameter to overwrite the global. But I don't think directly in JDocument, or even the document's head renderer when the <title> element is generated, are the right spot for this.

avatar ggppdk
ggppdk - comment - 20 Jul 2016

@smehrbrodt

Ok, speaking of titles, i want to comment on your issue title

your description is good, but the title of your issue makes it sound like a bug,
and as your description makes clear there is no bug

I think you can change title of this issue to

Improve JDocument::setTitle to use automatically: "Show page name in title", to avoid code duplication

I agree with doing something with code duplication, (which can do in your custom app too, and i was thinking of doing too, because i dislike having to change many files using the same code when such a need arises)

  • but this is better not be in JDocument::setTitle , instead some helper method ( mbabker explained )

this is nice to do but low priority

avatar smehrbrodt
smehrbrodt - comment - 20 Jul 2016

So what would be a suitable place for such a helper method?

avatar OctavianC
OctavianC - comment - 20 Jul 2016

I'm +1 with @smehrbrodt on this one; I don't see the reason to have a global setting and have every view from a component check that setting and duplicate code all over. It always annoyed me. Perhaps this should be built in the view model? So we can use a protected/private method ->setTitle()?

avatar brianteeman brianteeman - change - 21 Jul 2016
Labels Added: ?
avatar ggppdk
ggppdk - comment - 21 Jul 2016

@smehrbrodt
i am not sure, maybe this can be a new Method in JLegacyView ?

setConfiguredTitle($title)

avatar brianteeman brianteeman - change - 23 Jul 2016
Category Libraries
avatar brianteeman
brianteeman - comment - 2 Aug 2016

Closed as we have a pr for testing #11399

avatar brianteeman brianteeman - change - 2 Aug 2016
Status New Closed
Closed_Date 0000-00-00 00:00:00 2016-08-02 12:53:26
Closed_By brianteeman
avatar brianteeman brianteeman - close - 2 Aug 2016

Add a Comment

Login with GitHub to post a comment