Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » $option wouldn't trigger MetaMod rules
$option wouldn't trigger MetaMod rules
$option wouldn't trigger MetaMod rules
Hi, I've been trying to figure it out, looked through the Forum messages but still unable to resolve it.
The problem is simple in nature, we can only engage MetaMod with com_content (sections/categories/articles) however when I try to link com_civicrm, or com_search, or com_joomdoc nothing happens: the default module shows up.
When I pulled the value of $option variable through PHP insertion into the template code it returned proper values of com_civicrm (etc).
echo 'option = ' .$option .'<br />';
echo 'pageview = ' .$pageview.'<br />';
Here's the MetaMod config:
--------------------------------------------
// example: return 23;
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 customize 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 == 0) return 67;
if ($section_id == 1) return 67;
if ($section_id == 5) return 64;
if ($section_id == 6) return 56;
if ($section_id == 7) return 68;
if ($section_id == 8) return 69;
if ($section_id == 9) return 69;
if ($option == 'com_civicrm') return 56;
}
return 67; /* default if nothing else matches */
------------------------------------------
MetaMod 2.3
Joomla 1.5.14
The site also runs CiviCRM, JoomDoc, JEvents and SW Menu Pro.
http://friendsnrc.alloraconsulting.com/ … n-contacts <-- proper menu displayed (56)
http://friendsnrc.alloraconsulting.com/ … p;search=0 <-- menu switches to the default one (67 vs 56)
Re: $option wouldn't trigger MetaMod rules
Hi sergeich,
The reason for this is that your check for com_civicrm is INSIDE the last } bracket. This puts it inside the block that begins "if ( $option == 'com_content' && $view != 'frontpage' ) {".
So logically $option can't be com_civicrm when it's inside that block.
Fix: put your com_civicrm check AFTER the final } instead of before it.
By the way, I just released MetaMod 2.4. It has a new feature in it called JomGenius. If you install v2.4, you can replace your entire rule with this:
if ( $content_genius->check( "section_id = 0, 1" ) ) return 67;
if ( $content_genius->check( "section_id = 5" ) ) return 64;
if ( $content_genius->check( "section_id = 6" ) ) return 56;
if ( $content_genius->check( "section_id = 7" ) ) return 68;
if ( $content_genius->check( "section_id = 8,9" ) ) return 69;
if ( $option == "com_civicrm") ) return 56;
return 67;
Much nicer, I think!
Cheers,
Stephen
Re: $option wouldn't trigger MetaMod rules
Sweet, it worked like a charm, thanks a bunch!
I do remember trying putting the civicrm statement oustide of "}" but I probably messed up something else along the way.
---
I updated MetaMod to 2.4b and the new script didn't engage while the old one worked. I uninstalled MetaMod entirely and installed the 2.4b from scratch: still no cigar. However the old config-script works fine.
Re: $option wouldn't trigger MetaMod rules
Hi again,
I just fixed some (more) bugs in the content stuff in JomGenius. It's now released in MetaMod 2.4c. Would you mind installing the newer version and trying that with the new-style rules?
Also, if you installed MetaTemplate or MetaTemplate Pro, then the JomGenius libraries from them get used instead of the MetaMod ones. So you need to update them as well (otherwise the new version of MetaMod won't actually make any difference). The new version of MetaTemplate is 1.5c.
Sorry for the inconvenience! But at least you're helping to catch these bugs early... thank you for your help in this
Cheers,
Stephen
- Index
- » MetaMod
- » MetaMod General Support
- » $option wouldn't trigger MetaMod rules
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5942
- Posts this week:
- 2
- User Info:
- Total Users:
- 7627
- Newest User:
- rudys68879
- Members Online:
- 0
- Guests Online:
- 176
- Online:
- There are no members online
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked