J4 Plugin Example cum Tutorial - Article ToC

Be informed that this forum is not an official support forum for Joomla! 4.0. Any issues regarding Joomla! 4.0 must be reported at https://issues.joomla.org/.

Joomla! 4.0 is still in its Alpha stage. This forum should be used for sharing information about Joomla! 4.0.

Moderator: ooffick

Post Reply
ceford
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Mon Feb 24, 2014 10:38 pm

J4 Plugin Example cum Tutorial - Article ToC

Post by ceford » Tue Aug 20, 2019 10:07 am

I have created a J4 Plugin and explained how it works for those new to J4. It creates an Article Table of Contents from headings using a {ToC} placeholder. It is on Github:

https://github.com/ceford/j4xdemos-plg-toc

with the explanation in the Wiki. As ever, comments welcome. I am myself new to J4 and could be making blunders.

Cliff

SharkyKZ
Joomla! Ace
Joomla! Ace
Posts: 1636
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: J4 Plugin Example cum Tutorial - Article ToC

Post by SharkyKZ » Tue Aug 20, 2019 12:10 pm

I'm not sure if it's documented anywhere but it's good practice to:

1. Lowercase the plugin name in manifest file and prefix it with plugin group (folder). So this:

Code: Select all

<name>PLG_J4XDEMOSTOC</name>
becomes this:

Code: Select all

<name>plg_content_j4xdemostoc</name>
2. Prefix all strings with plugin group, e.g. PLG_J4XDEMOSTOC becomes PLG_CONTENT_J4XDEMOSTOC.

Have you considered adding layouts? Currently you have hardcoded classes and inline styles which cannot be changed.

ceford
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Mon Feb 24, 2014 10:38 pm

Re: J4 Plugin Example cum Tutorial - Article ToC

Post by ceford » Tue Aug 20, 2019 1:59 pm

Thanks for the tips about including _CONTENT_ and making the manifest name lower case. This is my first publicly visible plugin so I had not appreciated those conventions. I have changed the language keys and included the tips in the tutorial.

As ever after something is finished and I am relaxing in the bath, I thought of adding custom parameters to allow the admin better control of appearance. Layouts? I don't know how to do that right now and I would be concerned that it might make the tutorial a tad complicated. Maybe a follow up tutorial: How to add a layout to a plugin, or something like that.

Thanks for your comments.

Cliff


Post Reply

Return to “Joomla! 4 Related”