1

TLDR: Is there an easy way to include the same instance of a module in different posts with different settings in Joomla!?

What works: URL parameters. I can call the post with a URL to which I append parameters that the module queries. But this is cumbersome. I'm looking for a simpler solution.

I'm thinking of something like this: Is there a way that a module recognizes in which post it is currently displayed and examines the content of this post for a certain keyword? Then you could assign keywords to certain settings in the backend and if the module finds the keyword in the post, it takes over these settings.

Detailed description: I wrote a module that accesses a calendar on another server. In the Joomla! backend you can set which events should be displayed. In the module I access this settings with "$params->get('xyz')", e.g. "$params->get('eventtype')" It is working.

But there is a problem: I can use the module in different posts, but the same events are always displayed because the same settings are always used. There is no way to use different settings for different posts. Example: One post shows all events for children, the other post shows all events for seniors, a third post shows all events with free entry, etc.

2 Answers 2

2

Joomla's design allows you to have multiple instances of modules to allow you to undertake what you've explained you're trying to do.

Basic Implementation

The assignments tab in the module settings will let you assign modules to specific pages. So without a third party extension, this will let you choose between On all pages, No pages, Only on the pages selected, On all pages except those selected from the list.

So you could then make multiple instances of your module, each with filter parameter that you need, and then each assigned to the specific pages you want to have the version with those filter parameters appear on.

Advanced Implementation

I use a 3rd party extension called Regular Labs Advanced Module Manager which then extends the Module Assignment capabilities further, allowing all sorts of ways to assign modules.

Though you could further add code to your module to look at getting URL parameters to drive your filtering, I think that multiple module instances would give you some clarity in the backend to know what it is each instance of the module is doing.

0

I think the solution might be "the plugin". Plugins attach themselves. You can parse article data, article category, etc. You can use an article's extra fields to make things easier to recognize for the plugin so that when you mark a checkbox in the article, then the plugin may try to analyze this article and output different data.

Another way is an injected plugin - the more manual way. You place this plugin via article editor by some unique tag/placeholder like:

{my_special_module_detector options}content{/my_special_module_detector}

Simple image gallery works like that and injects pictures.

({gallery}imagefolder{/gallery})

The other other way is to make your own component which is mostly a copy of article component hooked with one of the menu options. It is more work, but it gives you full control over the content area and you decide what's there.

Not everything can be treated as an article under Joomla. While you can distinguish them, you might opt for a custom component and drive things your way.

The custom component method gives you the ability to completely control everything - your views, your models and your buisness logic. Basically you're writing your own application on !J framework, something like AoF/FoF (Application on Framework / Framework on Framework).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.