For an extension I have, I need to grab the article text from a certain article (different to the current article) and pas that through the content & system plugins via the onContentPrepare
.:
JFactory::getApplication()->triggerEvent(
'onContentPrepare',
['com_content.article', &$article, &$article, 0]
);
I need to do this during the onAfterRender stage.
This works fine in Joomla 3.
However, in Joomla 4 this causes issues with the emailcloak plugin that tries to load assets: WebAssetManager->useAsset()
.
The resulting error is:
0 WebAssetManager is locked, you came late
So the question is:
Is this something that can be fixed? Or is there some other way that makes it possible to parse article objects through the plugins after the WebAssetManager gets locked without running into fatal errors?
Labels |
Added:
?
|
Title |
|
I think I can deal with my current hurdle by using the onAfterRenderModules instead.
It is a shame though that it is not possible to just parse a piece of text through the plugins at any stage, when you don't care about the scripts/styles...
It is a shame though that it is not possible to just parse a piece of text through the plugins at any stage
onContentPrepare
meant to be run while dispatching of the component, this is by design.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-05-19 18:29:12 |
Closed_By | ⇒ | regularlabs |
Well, actually when rendering articles (or object disguised as articles).
I know that. But plugins (and possibly other extensions) need to be able to pass content through the plugins (specifically the onContentPrepare
) for whatever reason. Which the can, that's why Joomla uses the events system.
It is just that the decision to not ignore silently anymore takes away some flexibility that was there in Joomla 3.
But I'll work my way around it. No problem.
This was made to prevent adding an assets after rendering. because the document is rendered and nothing can be added to it.
In past it was just ignored silently.
Last chance to do anything with assets is
onBeforeCompileHead
I do not think that it is good idea to call
onContentPrepare
after render, there maybe more extensions, that may lead to weird things.Maybe try another event like
onBeforeRender
, or maybeonAfterRenderModules
(not sure here).