editors-xtd and content display

23 views
Skip to first unread message

Allan Jardine

unread,
Nov 1, 2021, 8:15:00 PM11/1/21
to Joomla! General Development
Hi all,

I'm new to developing plug-ins for Joomla, so my apologies if I get any of the terminology wrong. Also, this is cross posted from the Joomla forum - I should have posted here in the first place - sorry.

I've successfully created an `editors-xtd` plug-in to add a button below the editing panel (by basing it on the core's own plug-ins). I don't get how I can control the layout of the iframe stuff yet, but I haven't looked into it properly.

The main issue I'm having trouble with is that I need to modify the content of an article before it is displayed. I can't just insert HTML into the editor as I need temporary tokens when the page is loaded. So my plan was to have the editors-xtd plug-in insert a token such as `[embed 1234]` and then transform that on output with `onContentPrepare`. This is where the wheels come off.

How can I have my editors-xtd plug-in also operate on the content output? Brian in the forum noted I can't use `onContentPrepare` in an editors-xtd plug-in. In which case how can I add an option to the editor and also modify the output when displayed to the end user?

Thanks,
Allan

Roger Creagh

unread,
Nov 2, 2021, 9:00:49 AM11/2/21
to joomla-de...@googlegroups.com
I think the answer is that you actually create two plugins - an editors-xtd one to make an editor button which inserts the shortcode for the what you will want to insert (the convention is to use {} curly braces around the shortcode) and then a content plugin to convert the shortcode into the content you wish to insert onContentPrepare

Or at least as I remember that's what I did for my footnote plugin - https://crosborne.uk/jplugins/footnote-tag which might give you some clues

RogerCO
--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/joomla-dev-general/1790c192-758c-40e2-a04d-5c0484201fafn%40googlegroups.com.

Allan Jardine

unread,
Nov 3, 2021, 4:47:40 AM11/3/21
to Joomla! General Development
Hi Roger,

Many thanks for your reply and the link to your plug-in. That is really useful, particularly the install package script - thank you!

One thing I'm not clear on is how to share configuration settings between the two plug-ins. Do you (or anyone else who can chime in) know how that can be done?

Thanks,
Allan

Allan Jardine

unread,
Nov 8, 2021, 12:16:32 PM11/8/21
to Joomla! General Development
In case anyone else finds this post and isn't sure how to do it, I found that you can call:

$plugin = JPluginHelper::getPlugin('content', 'pluginname');

Then:
$pluginParams = new JRegistry($plugin->params);
$apiKey = $pluginParams->get('paramName');

I'm sure it will be documented somewhere - but I couldn't see it. Found it by digging through other plug-ins such as Roger's :-).

Thanks,
Allan
Reply all
Reply to author
Forward
0 new messages