Module in single article accessed from category blog

General questions relating to Joomla! 3.x. Please consider the availability of third-party templates and extensions when deciding which Joomla version to use.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
User avatar
andypooz
Joomla! Guru
Joomla! Guru
Posts: 696
Joined: Sat Dec 30, 2006 3:03 pm
Location: London, UK
Contact:

Module in single article accessed from category blog

Postby andypooz » Thu Mar 08, 2018 9:20 am

Has anyone got a trick for getting a module to appear on any single article page accessed from a category blog (with no menu item for the single article) when the module is not set to appear on the category blog page (which does have a menu item)?

I'm well aware of the Joomla module-by-menu-item paradigm of Joomla, and I'm quite happy with it, but I have had this requirement a few times and never quite found a good solution (or any solution to be honest).

As I want my module to appear at the bottom of my content, I could create my module content as a content plugin and put the tag at the bottom of each article in the editor. As long as all articles in the blog had the tag below the read more (and no full articles), then that would work, but I'm convinced there's a far easier and more adaptable way.

I'd rather not use an additional extension that provides advanced control of modules, but if anyone has one that works well, I'm open to suggestions.
Andy Hickey
Bespoke Joomla Extension Developer
http://www.netamity.com

SharkyKZ
Joomla! Guru
Joomla! Guru
Posts: 921
Joined: Fri Jul 05, 2013 10:35 am
Location: Unknown

Re: Module in single article accessed from category blog

Postby SharkyKZ » Thu Mar 08, 2018 9:39 am

As I want my module to appear at the bottom of my content, I could create my module content as a content plugin and put the tag at the bottom of each article in the editor.


Inserting plugin tags to articles isn't necessary. The plugin could be coded to work without them. So this can be a pretty good and easy option.

Joomla's way of displaying modules in articles is by using 'Content - Load Modules'. But this does require inserting plugin tag to each article. Not a suitable option if you want module to appear in all articles.

Third and probably easiest option is to create a custom module position in article template, like so:

Code: Select all

echo JFactory::getDocument()->loadRenderer('modules')->render('mymoduleposition');

User avatar
andypooz
Joomla! Guru
Joomla! Guru
Posts: 696
Joined: Sat Dec 30, 2006 3:03 pm
Location: London, UK
Contact:

Re: Module in single article accessed from category blog

Postby andypooz » Thu Mar 08, 2018 10:11 am

The third option make so much sense! Thank you! I'll do that in my template overrides today. What could be easier?!

It wouldn't help if you wanted to control the modules displayed in a sidebar of course, but its perfect for what I need
Andy Hickey
Bespoke Joomla Extension Developer
http://www.netamity.com

User avatar
effrit
Joomla! Guru
Joomla! Guru
Posts: 595
Joined: Sun Nov 12, 2017 2:21 pm
Location: middle of Russia
Contact:

Re: Module in single article accessed from category blog

Postby effrit » Thu Mar 08, 2018 11:49 am

just make condition in your template to show special module position only on article view:

Code: Select all

if($_REQUEST["view"]=="article"):?>
<jdoc:include type="modules" name="myposition" style="none" />
<?php endif;?>

venci
Joomla! Apprentice
Joomla! Apprentice
Posts: 45
Joined: Sat Nov 17, 2012 6:10 am

Re: Module in single article accessed from category blog

Postby venci » Thu Mar 08, 2018 12:32 pm

Hi effrit,
I think you have a technical error in the first line.
It must be :

Code: Select all

<?php if($_REQUEST["view"]=="article"):?>

User avatar
andypooz
Joomla! Guru
Joomla! Guru
Posts: 696
Joined: Sat Dec 30, 2006 3:03 pm
Location: London, UK
Contact:

Re: Module in single article accessed from category blog

Postby andypooz » Thu Mar 08, 2018 12:35 pm

Great suggestions. Thanks.
Andy Hickey
Bespoke Joomla Extension Developer
http://www.netamity.com


Return to “General Questions/New to Joomla! 3.x”

Who is online

Users browsing this forum: No registered users and 26 guests