? Pending

User tests: Successful: Unsuccessful:

avatar joomdonation
joomdonation
30 Dec 2017

Pull Request for Issue # .

Summary of Changes

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

Testing Instructions

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.

avatar joomdonation joomdonation - open - 30 Dec 2017
avatar joomdonation joomdonation - change - 30 Dec 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 30 Dec 2017
Category Libraries
avatar joomdonation joomdonation - change - 31 Dec 2017
Labels Added: ?
avatar ggppdk
ggppdk - comment - 2 Jan 2018

You can use method
public function setDocumentTitle($title)
#11399

exists inside same class, so your setDocumentHeadData() could make use of it

avatar joomdonation
joomdonation - comment - 2 Jan 2018

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

avatar ggppdk
ggppdk - comment - 2 Jan 2018

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()

avatar ggppdk
ggppdk - comment - 2 Jan 2018

About removing it

  • someone would want to call setDocumentHeadData()
  • and then call setDocumentTitle($title) to override only the title

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

avatar joomdonation
joomdonation - comment - 2 Jan 2018

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.

avatar ggppdk
ggppdk - comment - 2 Jan 2018

yes, that s why i said that my 2nd suggestion is better,
it is best to have 2 methods with distinct functionality

avatar joomdonation
joomdonation - comment - 2 Jan 2018

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?

avatar mbabker
mbabker - comment - 4 Jan 2018

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.

avatar joomdonation
joomdonation - comment - 5 Jan 2018

@mbabker I change it to pass $params as method parameter. Hope it is OK now.

61629ed 5 Jan 2018 avatar joomdonation Typo
avatar brianteeman
brianteeman - comment - 8 May 2018

@mbabker are the changes better now or are your comments still valid in which case this should be closed

avatar mbabker
mbabker - comment - 8 May 2018

Seems fine as is

avatar joomdonation joomdonation - change - 3 Oct 2018
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2018-10-03 01:31:07
Closed_By joomdonation
avatar joomdonation joomdonation - close - 3 Oct 2018

Add a Comment

Login with GitHub to post a comment