User tests: Successful: Unsuccessful:
Pull Request for Issue # .
In view classes of a component, we usually have to set document head data like page title, description, meta keywords, meta description, robots...
Instead of writing that repeating code again and again in every view, this PR introduces a new method called setDocumentHeadDatas to do that work. Component view classes now only need to set necessary data to $params property of the view if needed and call setDocumentHeadDatas method to set these data for document
Code review for now. If the concept is accepted, I will convert actual view classes (like category view) to use this new method and human testing will be needed at that time.
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Labels |
Added:
?
|
Yes, I am aware of that method. I just think maybe we don't need that method in the future, so sometime it can be deprecated and can be removed from the class in the future
Reasoning for adding setDocumentTitle($title) is same as adding setDocumentHeadData()
i would argue to make use of it, and reduce the code size of setDocumentHeadData()
About removing it
Also It is probably best to completly remove the "title" code from setDocumentHeadData()
and then you have 2 small methods to call inside views like this:
$this->setDocumentTitle();
$this->setDocumentHeadData(); // or maybe "setDocumentMeta()" or something
Thus you achieve both replacing the repeatable code,
and also making things easier in terms of overriding the default behavour,
more clean and more flexible
I don't think it is good to call setDocumentHeadData and then call setDocumentTitle($title) to override only the title. If we do that, we would have the same code run two times, it is a waste of resource. It is better to call $this->params->set('page_title', $title) before calling setDocumentHeadData();
If we have a use case which we only need to set page title, not other meta data like description, robots..., on a View class, then Yes, we should keep setDocumentTitle and use it on setDocumentHeadData. Otherwise, I would like to keep the code as how it is at the moment.
yes, that s why i said that my 2nd suggestion is better,
it is best to have 2 methods with distinct functionality
I still prefer one method call per view only. I don't like having to call two methods:
$this->setDocumentTitle();
$this->setDocumentHeadData();
Can we get feedback from PLT about this?
Can't say I'm a fan of this. It's introducing more undocumented class member variables into a base class we already have problems with having undocumented variables on. And it's making a hard reservation on the $params
variable, both in terms of name and data type.
Seems fine as is
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-10-03 01:31:07 |
Closed_By | ⇒ | joomdonation |
You can use method
public function setDocumentTitle($title)
#11399
exists inside same class, so your setDocumentHeadData() could make use of it