? ? Pending

User tests: Successful: Unsuccessful:

avatar korenevskiy
korenevskiy
13 May 2022

Pull Request for Issue # .

Summary of Changes

Added position in the lists of articles of categories, archives selected. This position is displayed after this list of articles.

This is necessary for the subsequent withdrawal of information about this list of articles.
It will be convenient to use the list of category articles to create a form of ordering goods. Each material may have a selection field. And at the very end you can place an order form with delivery fields and contact details. And all this will be able to perform one field.

Testing Instructions

You need to create the onContentAfterItems($context, $item, $params) method in any content plugin
Then in this method return additional text.
This text will be inserted into the list of articles of the Blog or other list of articles .

public function onContentAfterItems($context, $item, $params) : string{
	return "<h3>This insert text in list articles</h3>";
}

The event of a trigger is caused by this code inserted at the end of the category blog.

$results = $app->triggerEvent('onContentAfterItems', array($this->category->extension . '.categories', &$this, &$this->params));
$afterDisplayItems = trim(implode("\n", $results));
echo $afterDisplayItems;

Actual result BEFORE applying this Pull Request

Before all positions allowed to add and process text before to location position the list of articles.
This approach is convenient for the output of ordinary material, but not for categories and lists of articles .

Expected result AFTER applying this Pull Request

But when displaying a list of articles, the list itself is important, so you need to display data before the list and after the list of articles.

Documentation Changes Required

https://docs.joomla.org/Plugin/Events/Content
https://docs.joomla.org/J3.x:Creating_a_content_plugin

avatar korenevskiy korenevskiy - open - 13 May 2022
avatar korenevskiy korenevskiy - change - 13 May 2022
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 13 May 2022
Category Front End com_content
avatar korenevskiy korenevskiy - change - 13 May 2022
The description was changed
avatar korenevskiy korenevskiy - edited - 13 May 2022
avatar korenevskiy korenevskiy - change - 14 May 2022
The description was changed
avatar korenevskiy korenevskiy - edited - 14 May 2022
avatar korenevskiy korenevskiy - change - 14 May 2022
The description was changed
avatar korenevskiy korenevskiy - edited - 14 May 2022
avatar korenevskiy korenevskiy - change - 14 May 2022
Labels Added: ?
avatar korenevskiy korenevskiy - change - 16 May 2022
The description was changed
avatar korenevskiy korenevskiy - edited - 16 May 2022
avatar korenevskiy korenevskiy - change - 16 May 2022
The description was changed
avatar korenevskiy korenevskiy - edited - 16 May 2022
avatar korenevskiy korenevskiy - change - 16 May 2022
The description was changed
avatar korenevskiy korenevskiy - edited - 16 May 2022
avatar korenevskiy korenevskiy - change - 16 May 2022
The description was changed
avatar korenevskiy korenevskiy - edited - 16 May 2022
avatar laoneo
laoneo - comment - 13 Jun 2022

Personally I think we have enough display events.

If you still think we should add these events to core, then they must be triggered in the view and the layout files (like default.php) have then to render only the output. An example can be found here https://github.com/joomla/joomla-cms/blob/4.1-dev/components/com_content/src/View/Article/HtmlView.php#L245-L253

avatar korenevskiy
korenevskiy - comment - 15 Jun 2022

Personally I think we have enough display events.

If you still think we should add these events to core, then they must be triggered in the view and the layout files (like default.php) have then to render only the output. An example can be found here https://github.com/joomla/joomla-cms/blob/4.1-dev/components/com_content/src/View/Article/HtmlView.php#L245-L253

You are absolutely right. I think so too.
But, in the already existing Joomla code, everything is different.
Exactly in half the cases it was done as you say, but in the other half of the cases it has already been done in the render file.
In all cases, I would do as you advise, but then it will be correct for the first part of the calls, but for the second part of the calls it will not be correct.
Therefore, for the second half of the calls where the event calls are located in the render, I did the same, and added my corrections there.
My correction does not correct the structure of the Joomla render.
My correction is only made by the call trigger.
Structural renderetions must be made by separate PR. And conduct numerous tests. Perhaps structural fixes are no longer possible to fix, except in Joomla 5.

So what should I do? I cannot violate the existing render structure.
You have indicated a link over the view of the article. But if you look at the view of the category, then everything is done incorrectly.

avatar HLeithner
HLeithner - comment - 27 Jun 2022

This pull requests has automatically rebased to 4.2-dev.

avatar joomla-bot
joomla-bot - comment - 27 Jun 2022

This pull requests has been automatically converted to the PSR-12 coding standard.

avatar HLeithner HLeithner - change - 27 Jun 2022
Labels Added: ?
avatar korenevskiy korenevskiy - change - 1 Jul 2022
Labels Added: ?
avatar korenevskiy korenevskiy - change - 4 Jul 2022
Labels Removed: ?
avatar HLeithner HLeithner - change - 4 Jul 2022
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2022-07-04 12:09:15
Closed_By HLeithner
avatar HLeithner
HLeithner - comment - 4 Jul 2022

Sorry to say but this PR is conceptional wrong, we don't have events in layouts/templates if you want to change a layout then please override it.
Events are expensive so we have to be very careful using them.

avatar HLeithner HLeithner - close - 4 Jul 2022
avatar HLeithner
HLeithner - comment - 4 Jul 2022

I got notified that my closing comment maybe sounds rude. This wasn't my intention and I apologies for this.

avatar korenevskiy
korenevskiy - comment - 4 Jul 2022

Why everything is being destroyed. Please understand me, I completely agree with you. I don't want to write an event call in layouts. But I couldn't do otherwise. because the other event calls are exactly there. I already wrote it above! The event call in the article is where it should be. But the category event calls are not there, this is a big mistake.

@HLeithner
components/com_content/tmpl/category/blog.php
https://github.com/joomla/joomla-cms/blob/4.2-dev/components/com_content/tmpl/category/blog.php#L21-L32
Look at this file yourself and see all the event calls. What can I do in this case?
I created this PR code, not because I don't know Joomla well, you made a mistake, I know Joomla well enough, and I know PHP well. I had no other choice.

avatar HLeithner
HLeithner - comment - 5 Jul 2022

@nibra https://github.com/joomla/joomla-cms/blob/4.2-dev/components/com_content/tmpl/category/blog.php#L21-L32 Look at this file and see all the event calls. Why deleted this PR?

Because they are wrong, a layout file shouldn't call any event. The code you have linked as more then one problem and we don't want to continue to make more broken code. If you look at the event refactor discussion at #36578 you may notice where the way should go with the event/message system.

And once again the Events manipulates the items (edit: ok not all of them) not the layout (adding text like your event) for this a layout override fits better and is more generic.

edit: We could add many other events for the layout stuff but that doesn't make sense in my opinion, the events we have are already too much.

Add a Comment

Login with GitHub to post a comment