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.

 

Recipe request

Recipe request

Hi, I need your help with a recipe
I am trying to combine several things into a metamodule.
I would like to only show the module in a category blog.
I would like to return the category id as a parameter
I would like to return the category title as the title for the module

Seperately I would like to do the same thing but for a section blog. returning the section id as a parameter and the section title as the title for the module.
Any help appreciated. (P.S. I have metamodpro).

adamwclarke
Beginner Modder
ranks
useravatar
Offline
14 Posts
Administrator has disabled public posting

Re: Recipe request

Hi Adam,

Can you explain "return the category id as a parameter" further? I'm not sure what you mean, unless you mean that you want to extract the category id (e.g. from the URL) and set some parameter of the *module* using that category id. Is that what you're after? For the sake of this example, I'll assume that's what you're after.

So try this:

Code:

// first get hold of the category id. This is only going to operate on a Category Blog page.

$mod_to_display = XXX; // replace XXX with module ID to display
$category_id = null;
if ( $option == "com_content" and $view == "category" ) {
  /* category list pages (blog or list style) */
  $category_id = (int)$id;
 
  $query = "SELECT  title "
    . " FROM #__categories WHERE id = $category_id AND published = 1";
  $db->setQuery( $query, 0, 1 );
  $row = $db->loadObject();
  $title = @$row->title;

  $changes->mod( $mod_to_display )->title($title)->setParam( 'some_module_parameter_here', $category_id );
  return $mod_to_display;
}

For sections it's pretty similar:

Code:

// first get hold of the section id. This is only going to operate on a Section Blog page.

$mod_to_display = XXX; // replace XXX with module ID to display
$section_id = null;
if ( $option == "com_content" and $view == "section" ) {
  /* section list pages (blog or list style) */
  $section_id = (int)$id;
 
  $query = "SELECT  title "
    . " FROM #__sections WHERE id = $section_id AND published = 1";
  $db->setQuery( $query, 0, 1 );
  $row = $db->loadObject();
  $title = @$row->title;

  $changes->mod( $mod_to_display )->title($title)->setParam( 'some_module_parameter_here', $section_id );
  return $mod_to_display;
}

Hope that helps,
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
3329 Posts
User info in posts
Administrator has disabled public posting

Re: Recipe request

Hi Stephen this worked a treat. Thanks

adamwclarke
Beginner Modder
ranks
useravatar
Offline
14 Posts
Administrator has disabled public posting

Re: Recipe request

Hi Stephen,

Thanks for this, I have an additional requirement. As per your recipe for the module title I am using the category or section name but i would also then like to have an additional word in the title to help with search engine visibilty. For example if my category is "Sydney" I would like to add the word "News" after it e.g Sydney News. If another category was Melbourne, it would be Melbourne News. Thus the title will change with the section of category, but the word News remains fixed.

I know it requires modification of the code in bold but I dont know how:


$changes->mod( $mod_to_display )->title($title)->setParam( 'some_module_parameter_here', $section_id );
  return $mod_to_display;

Could you help, I imagine this is simple if you know the code.

Thanks in advance

adamwclarke
Beginner Modder
ranks
useravatar
Offline
14 Posts
Administrator has disabled public posting

Re: Recipe request

Hi Adam,

ok, that's pretty simple.

Replace the appropriate line above with:

$changes->mod( $mod_to_display )->title($title . " News");

Note, unless you know you need it, you don't need that additional "setParam(...)" part of the line I mentioned in the original recipe.

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
3329 Posts
User info in posts
Administrator has disabled public posting

Re: Recipe request

Hi,
Similiar to this thread is it possible to pull down the category name and the section name and parse this into parameter fields of a module at the same time?

Thanks
Adam

adamwclarke
Beginner Modder
ranks
useravatar
Offline
14 Posts
Administrator has disabled public posting

Re: Recipe request

Hi Adam, yes, that's possible, and even easier to do now with JomGenius (requires latest version of MetaMod). See the JomGenius documentation for more info.

$mod_to_display = XXX; // replace XXX with module ID to display
$section_title = $content_genius->info("section_title");
$category_title = $content_genius->info("category_title");

$changes->mod( $mod_to_display )->title($section_title . " - " . $category_title);
// or, for an arbitrary parameter:
// $changes->mod( $mod_to_display )->setParam( "some_module_parameter_here", $section_title . " - " . $category_title );
return $mod_to_display;

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
3329 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1689
Total Polls:
6
Total Posts:
5941
Posts this week:
1
User Info:
 
Total Users:
5355
Newest User:
titus87954
Members Online:
3
Guests Online:
104


Forum Legend:

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