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.
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)
this is nice to do but low priority
So what would be a suitable place for such a helper method?
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()
?
Labels |
Added:
?
|
@smehrbrodt
i am not sure, maybe this can be a new Method in JLegacyView ?
setConfiguredTitle($title)
Category | ⇒ | Libraries |
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-08-02 12:53:26 |
Closed_By | ⇒ | brianteeman |
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.