[jgen] onContentPrepare event too limited

348 views
Skip to first unread message

parvus parvus

unread,
Sep 27, 2011, 1:13:07 AM9/27/11
to joomla-de...@googlegroups.com
Since 1.6, the onContentPrepare event only contains the article text.
This is problematic for a lot of content plugins (e.g. readlesstext)
See tracker id 24340:
http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=24340

Is there a way to get the full article information? It seems that CM
Auto Readmore has found a way, see
http://extensions.joomla.org/extensions/news-display/articles-summary/17979

I would very much want to develop for 1.6+, if I only would know how...

Thanks,
parvus

--
http://www.fastmail.fm - mmm... Fastmail...

Nick Savov

unread,
Sep 27, 2011, 1:45:02 AM9/27/11
to joomla-de...@googlegroups.com
Hi Parvus,

Check out Michael Babker's and Andrea Forghieri's workarounds in the
tracker item that you mentioned.

Kind regards,
Nick

> --
> You received this message because you are subscribed to the Google Groups
> "Joomla! General Development" group.
> To post to this group, send an email to
> joomla-de...@googlegroups.com.
> To unsubscribe from this group, send email to
> joomla-dev-gene...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
>
>

parvus parvus

unread,
Sep 27, 2011, 2:10:13 AM9/27/11
to Joomla general development
Hi,

Thank you. I somehow missed Andrea's suggestion.

Michael's suggestion crossed my mind too, but is impractical. Querying
the database on the introtext field is hardly a solution to consider. an
content plugin can be scheduled to run before or after other content
plugins. Any content plugin can - and probably will - alter the
contents. A query will then not give any result. Or: what to when a
query yields two or more results? This solution is not feasible.

Regarding Andrea's suggestion: I can't find any information on the
onContentBeforeDisplay event - except how to code for it. What is this
event (originally) meant for? What is the difference with
onContentPrepare (except the available information, that is)? How this
event fit architecurally?

Also, on StackOverflow, I found this:
http://stackoverflow.com/questions/6056886/joomla-plugin-how-to-get-article-tile-and-article-id
Haven't tried it out yet, though.

Greetings,
parvus

On Tuesday, September 27, 2011 12:45 AM, "Nick Savov"

--
http://www.fastmail.fm - IMAP accessible web-mail

Michael Babker

unread,
Sep 27, 2011, 6:44:33 AM9/27/11
to joomla-de...@googlegroups.com
I'm using the method I suggested for two plugins on my site thus far
without issue; one of which is JED listed. As you said, doing that does
have a chance to return multiple results. However, given the way data is
currently handled, it's the best workaround I can come up with. At the
least, adding the ID to the data being passed to onContentPrepare in these
instances would help out a lot.

Michael Babker

unread,
Sep 28, 2011, 1:29:03 PM9/28/11
to joomla-de...@googlegroups.com
It was stated earlier that there's a reason that the full article object
isn't being passed to onContentPrepare. Between two patches I've posted,
I think there is a viable solution available for all devs:

1)
http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tra
cker_item_id=24340 - Passes the ID as well as the introtext objects to
onContentPrepare
2)
http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tra
cker_item_id=26421 - Adds a context to all views passing to
onContentPrepare via JHtmlContent::prepare (includes the com_content
category and featured views)


Note that the platform change that was required for the context has
already been committed and was included in the Platform 11.2 tag which is
the platform version in J! 1.7.1.

Emerson da Rocha Luiz

unread,
Sep 28, 2011, 2:19:52 PM9/28/11
to joomla-de...@googlegroups.com

Just a question simple question: and about performance? Pass entire object didint make diference?

Is is not really used os at least good part of plugins os this type, and have a good (and documented) workaroud why not just stay as is since j16?

att. Emerson
/android

parvus parvus

unread,
Oct 27, 2011, 5:23:24 AM10/27/11
to Joomla general development
(time flies)

I am now using the onContentBeforeDisplay() event in my content plugin,
but this comes with its own set of problems, so it seems.

- I noticed that this indeed gives the full article object, but it
doesn't seem to play nice for the featured view:
- On 1.6, the fulltext field is not defined,
- On 1.7, the fulltext field is empty.
And this even if fulltext does exist in the database. This only
happens in a "featured" view, not in a category view or any other
view.

- Worse, the event is even not triggered in the categories view: the
code in components/com_content/views/categories/view.html.php lacks any
trigger calls.


Is this all intended behavior from the core? Or am I missing something?
Greetings,


On Wednesday, September 28, 2011 9:59 PM, "Michael Babker"

--
http://www.fastmail.fm - The way an email service should be

Mark Dexter

unread,
Oct 27, 2011, 12:22:07 PM10/27/11
to joomla-de...@googlegroups.com
It sounds like it could be a bug. Could you please check the Issue Tracker to see if it is already there and, if not, please add it? If you add it, it would be wonderful if you could also include a sample plugin that demonstrates the bug. Thanks. Mark
Reply all
Reply to author
Forward
0 new messages