Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Way to simply RUN a module or plugin instead of CALLING it?

Way to simply RUN a module or plugin instead of CALLING it?

I'm creating separate article content for different parts of pages, so for instance I have a Default Banner article and a Default Side Content article, and many alternatives of those for different pages.  To get them to load on a page, I can use the include_content_item module, which lets me insert any article into a module position by entering the code {include_content_item 40} to show article id 40 for instance.  I'm going to have almost 20 different Banners and about 10 different articles for Side Content.  That means I'd normally end up with about 30 include_content_item modules.  I'll have MetaMod choose which Banner and Side Content module to display on different pages.

Is there any way to skip the individual module creation and have MetaMod directly output and parse the {include_content_item 40} code?  That way I could just setup the MetaMod and eliminate the 30 other modules.  I've tried many different methods so far and nothing has worked.  If I output the plugin code from MetaMod it doesn't get parsed.

One method simply grabbed the introtext field for the article from the database, but then of course it outputs the raw content and ignores any content plugins.

This would be so extremely helpful.  Any ideas?

Thanks,

Magestyx

magestyx
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: Way to simply RUN a module or plugin instead of CALLING it?

Hi Magestyx,

You're right, content output directly from MetaMod doesn't get passed through the plugins, and I'm probably not going to be adding that function in the short term. (possible for the future).

What I can recommend however is using the MetaMod "Module Param Control" functionality:

http://www.metamodpro.com/metamod/contr … parameters

What this means, is that in MetaMod you can include a module (e.g. the include_content_item module you mention), then dynamically change the parameters in that module. You only need ONE include_content_item module!!!

In this case, you could tell the include_content_item module to show a different module ID.

The parameter name in the include_content_item module is "content". (I just checked)

So you would do this:

$mod = XXX; // replace XXX with the include_content_item module id
$article = null;
if ( conditions here..... ) {
  $article = "40"; // for example...
}
if ( other conditions here..... ) {
  $article = "41"; // for example...
}
if ($article != null) {
  $changes->mod($mod)->setParam("content","{include_content_item " . $article . "}");
  return $mod;
}

Hope that helps - I think it's a good solution.
Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3314 Posts
User info in posts
Administrator has disabled public posting

Re: Way to simply RUN a module or plugin instead of CALLING it?

Thaaaat's it-- you're on my list to donate to at the end of this project (and/or I'll purchase MetaMod Pro).

Man, I tried to get that to work for literally HOURS over the past couple days.

This works great, and the plugins I have setup in the article content are also kicking in just fine, so it looks like I'm all set with this issue.

Thanks so much!

Magestyx

---------
Final code
---------

// the original include_content_item module id
$mod = 83;


switch (miPageThemer('bannerToLoad')){
    case "banner-default-lg":
        $article = "40";
        break;
    case "banner-default-md":
        $article = "42";
        break;
    case "banner-default-sm":
        $article = "43";
        break;
}


$changes->mod($mod)->setParam("content","{include_content_item " . $article . "}");

return $mod;

magestyx
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: Way to simply RUN a module or plugin instead of CALLING it?

Hi magestyx,

I'm glad that works so well! Just a note: what happens when miPageThemer() doesn't return one of those options? Then $article is undefined. Best put in a check for that unless you're absolutely sure that miPageThemer can only return the items you are checking for.

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3314 Posts
User info in posts
Administrator has disabled public posting

Re: Way to simply RUN a module or plugin instead of CALLING it?

Stephen,

yep, that was the first bug I came across-- I had to set a default.  The next step is that I'm going to pull the article's ID from the database directly according to the article's alias, which will be what miPageThemer() will create.  That way I won't even have to add in a case for all the possibilities.

This is going to make page theming a breeze, while using only my one base template.

Thanks again!

magestyx
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: Way to simply RUN a module or plugin instead of CALLING it?

Just a thought - why don't you use the recipe on this site for controlling modules via the article keyword parameter? Then, to add a module for any given article, you just add a keyword to the meta keywords. It could be either a keyword like "MOD_LG", or include the module ID e.g. "MOD_40". I s'pose in some ways this is just swapping the use of the alias to the use of the metakeywords.

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3314 Posts
User info in posts
Administrator has disabled public posting

Re: Way to simply RUN a module or plugin instead of CALLING it?

Very interesting.  Yes, that could probably work as long as the meta keywords always were picked up.  I have several components that help with them since Joomla has such limited meta functionality on its own, but it sounds good enough to be worth a shot!

magestyx
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: Way to simply RUN a module or plugin instead of CALLING it?

You can pick up the metakeywords that are directly entered in the article with this code:

$kw = $content_genius->info("article_metakeywords");

or you can pick them up from the document object, which may/may not use the values after they have been changed by plugins: (it would be interesting to know...)

$document =& JFactory::getDocument();
$content = $document->getMetaData('keywords');

The rest of the recipe is here:
http://www.metamodpro.com/metamod/recip … escription

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3314 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1691
Total Polls:
6
Total Posts:
5912
Total Posts Today:
6
User Info:
 
Total Users:
11529
Newest User:
jame380003
Members Online:
1
Guests Online:
146

Online: 
jame380003

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked