Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

Metamod Problem

Metamod Problem

Hello,
my websites features several categories / sections with articles. I'm now interested in showing a modul only next to articles of a special category / section. So I installed the newest version of Metamod to the newest version of Joomla. The metamod modul and the modul I want to show next to the articles of a category are both active. But now I don't understand how to tell Joomla / Metamod that the modul is only beeing shown next to the articles of one section / category. The modul I want to show has the ID 56, Metamod has the ID 57. The section it should be displayed is 5.

Thx 4 help.

Edited By: Dennis84
28-Nov-09 17:30:47

Dennis84
Beginner Modder
ranks
useravatar
Offline
6 Posts
Administrator has disabled public posting

Re: Metamod Problem

Hi Dennis,

1 - make sure you follow carefully the instructions on this page: http://www.metamodpro.com/get-started/quick-start

For module 56, the one that you want the MetaMod to show, you can either:
a - unpublish it
b - set it to display on "None" Menu Items
c - change the module position on it to a position that does not appear on your page, e.g. "blablabla".

It's important to do one of these, to prevent the module from showing up on the page UNTIL the MetaMod includes it.

2 - take a look at this page: http://www.metamodpro.com/support/recip … e-category
There are 2 recipes on it, one for categories and one for sections.

Copy and paste whichever one you need into the PHP box in MetaMod. Then change the "rules" near the bottom of each recipe in order to customise for yoru particular section and module id.

e.g. for the Section recipe, you would need to delete the rules at the bottom of the recipe and simply replace with this one:

  if ($section_id == 5) return 56;

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

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

Re: Metamod Problem

Hi,
thx for help. But it still does not work.

The modul I want to include:
Show Title: Yes
Enabled: No
Position: Footer
ID: 56
The modul works fine and gets displayed on the website if enabled is set to "Yes". For my test i set it back to "No".

Joomla Data
Category
- Title: Overview
- Published: Yes
- Access Level: Public
- Section: Test section
- ID: 36

Section:
- Title: Test section
- Published: Yes
- ID: 5

Article ( i tried to see the modul ):
- Title: test article
- Published: Yes
- Section: Test section
- Category: Overview
- ID: 48


Metamod:
Title: MetaMod
Show Title: Yes
Enabled: Yes
Position: Footer
Menu Assignment: None
Caching: No Caching
Cache Time: 900
Debug: Off
Module Class Suffix: ( empty )
Start date: ( empty )
End datte: ( empty )
Time Zone: Joomla default
Show Quick modules: All users
Enable Geo IO: Disabled
Only these countries: ( empty )
Exclude these countries: ( empty )
Language handlich: Browseres preferred language
Preffed list of lanuguages: ( empty )
Strict language comparison: On
Stlye: Multiple Divs
Style override: ( Empty )
Auto-Enable: None
Quick module: ( empty )


First try of code usage:

Code:


$category_id = null;
if ( $option == "com_content" ) {
  if ( $view == "category" ) {
   /* category list pages (blog or list style) */
   $category_id = (int)$id;
  } else if (array_key_exists("catid",$_REQUEST)) {
   /* if the category id is in the URL */
   $category_id = (int)JRequest::getInt("catid",0);
  }
  if ( $category_id === null && $view == "article" ) {
   /* if it's an article page without the catid mentioned in the url */
   $nullDate = $db->Quote( $db->getNullDate() );
   $my_id = $db->Quote( $db->getEscaped( (int)$id ) );
   $jnow  =& JFactory::getDate();
   $now    = $db->Quote( $db->getEscaped( $jnow->toMySQL() ) );
   $query = "SELECT  title,  id,  catid "
       . " FROM #__content WHERE id = $my_id AND state = 1"
       . " AND ( publish_up = $nullDate "
       . " OR publish_up <= $now )"
       . " AND ( publish_down = $nullDate "
       . " OR publish_down >= $now  )";
   $db->setQuery( $query, 0, 1 );
   $row = $db->loadObject();
   $category_id = $row->catid;
  }
}
/* Now customise any of the following rules for your use.
* $category_id will correspond to the category id of the
* article being displayed (if one is being displayed!)
*/
  if ($category_id == 36) return 56;

Second try if code usage:

Code:


if ( $option == 'com_content' && $view != 'frontpage' ) {
  $section_id = null;
  if ( $view == 'section' ) {
   /* section list pages (blog or list style) */
   $section_id = (int)$id;
  } else if (array_key_exists('sectionid',$_REQUEST)) {
   /* if the section id is in the URL */
   $section_id = (int)JRequest::getInt('sectionid',0);
  }
  if ( $view == 'category' ) {
   /* if it's a category list or blog page, get the section that the
    * category is in
    */
   $my_id = $db->Quote( $db->getEscaped( (int)$id ) );
   $query = "SELECT section from #__categories where id = $my_id";
   $db->setQuery( $query, 0, 1 );
   $row = $db->loadObject();
   $section_id = (int)( $row->section );
  }
  if ( $section_id === null && $view == 'article' ) {
   /* if it's an article page without the sectionid mentioned in the
    * url, look up the section id for that article
    */
   $nullDate = $db->Quote($db->getNullDate());
   $my_id = $db->Quote( $db->getEscaped( (int)$id ) );
   $jnow  =& JFactory::getDate();
   $now   = $db->Quote( $db->getEscaped( $jnow->toMySQL() ) );
   $query = "SELECT  title,  id,  sectionid "
       . " FROM #__content WHERE id = $my_id AND state = 1"
       . " AND ( publish_up = $nullDate "
       . " OR publish_up <= $now )"
       . " AND ( publish_down = $nullDate "
       . " OR publish_down >= $now  )";
   $db->setQuery( $query, 0, 1 );
   $row = $db->loadObject();
   $section_id = $row->sectionid;
  }

  /* Now customise any of the following rules for your use.
   * $section_id will correspond to the section id of the
   * article being displayed (if one is being displayed!)
   */
  if ($section_id == 5) return 56;/* uncategorised, return module 54 */

}

Nothings happens on the website, the modul doesn't get displayed. The category inclusion is more relevant for me.

Big thx for help.


Edit: I forgot one thing. The test system does not use SEF404. The system I want to use Metamod uses SEF404. Is this a problem?

Dennis84
Beginner Modder
ranks
useravatar
Offline
6 Posts
Administrator has disabled public posting

Re: Metamod Problem

Hi Dennis,

wow, thanks for the detailed info! That helps to diagnose the issue.

All you need to do is to set the Menu Assignment for the MetaMod to the correct page. If it's assigned to "none" (as it is at the moment) then the MetaMod will never run its rules! So you might want it on "all", or restrict it to a certain set of pages on which the articles/categories might appear.

Once that part is working then you can really test the section/category code. At a glance it looks fine, but you'll soon see.

Best regards,
Stephen

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

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

Re: Metamod Problem

Hi again ( and thx for support ),
I tried "All" as well as one "Selected Menu Item from List". Opening the article on the websites shows a "Error loading Modules:" without further details on the website.

Now I activated the Debug System ( "On" ):

Code:


MetaMod debug info:
$option: com_content
$view: article
$id: 48:math
$Itemid: 53
$timezone: default
$language: de-de
$language_code: de
$language_region: de
Including modules: 56

Now I don't have an idea why I receive the error "Error loading Modules:"

Dennis84
Beginner Modder
ranks
useravatar
Offline
6 Posts
Administrator has disabled public posting

Re: Metamod Problem

ok, I should have seen that one coming! The reason is that it's trying to load module 56, which is currently disabled, and the "auto-enable" is turned off. Turn that on for "all" or "by id", it doesn't really matter which.

Sorry about that.
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

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

Re: Metamod Problem

It works on the test page.

I installed Metamod now on my main website. The page uses SEF404 to rewrite the url so it is fine for Google. I tried the following code:

Code:


$category_id = null;

if ( $option == "com_content" ) {

  if ( $view == "category" ) {

   /* category list pages (blog or list style) */

   $category_id = (int)$id;

  } else if (array_key_exists("catid",$_REQUEST)) {

   /* if the category id is in the URL */

   $category_id = (int)JRequest::getInt("catid",0);

  }

  if ( $category_id === null && $view == "article" ) {

   /* if it's an article page without the catid mentioned in the url */

   $nullDate = $db->Quote( $db->getNullDate() );

   $my_id = $db->Quote( $db->getEscaped( (int)$id ) );

   $jnow  =& JFactory::getDate();

   $now    = $db->Quote( $db->getEscaped( $jnow->toMySQL() ) );

   $query = "SELECT  title,  id,  catid "

       . " FROM #__content WHERE id = $my_id AND state = 1"

       . " AND ( publish_up = $nullDate "

       . " OR publish_up <= $now )"

       . " AND ( publish_down = $nullDate "

       . " OR publish_down >= $now  )";

   $db->setQuery( $query, 0, 1 );

   $row = $db->loadObject();

   $category_id = $row->catid;

  }

}

/* Now customise any of the following rules for your use.

* $category_id will correspond to the category id of the

* article being displayed (if one is being displayed!)

*/

  if ($category_id == 39) return 60;

Nothing happens. After adding

Code:


else return 60;

at the end of the code the modul gets displayed. Could it be that Metamod does not see the url parameters now and does not display the module? Is there a solution?


EDIT: It seems to work now smile I will play a bit around with it and add several modules to find it out in the next 1-2 days. I'll report here as soon as I have a result.

Dennis84
Beginner Modder
ranks
useravatar
Offline
6 Posts
Administrator has disabled public posting

Re: Metamod Problem

It works smile Thx for the great support.

Dennis84
Beginner Modder
ranks
useravatar
Offline
6 Posts
Administrator has disabled public posting

Re: Metamod Problem

Great, I'm glad you got to the bottom of it. Were there any particular tricks to getting it going that you can share with us?

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

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

Re: Metamod Problem

metamodguy wrote:

Great, I'm glad you got to the bottom of it. Were there any particular tricks to getting it going that you can share with us?

Cheers,
Stephen

I think the important thinks can be found in this thread.

But maybe two things for the Metamod website:
- Metamod also works with SEF404 enabled.
- Add the section / category code to the FAQ ( as a link )*

* That's where I tried to find it.

Dennis84
Beginner Modder
ranks
useravatar
Offline
6 Posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1436
Total Polls:
6
Total Posts:
5118
Posts this week:
9
User Info:
 
Total Users:
4660
Newest User:
Rewegrons
Members Online:
1
Guests Online:
122

Online: 
Rewegrons

Forum Legend:

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