Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » Help with standard Sobi2 Recipe
Help with standard Sobi2 Recipe
Help with standard Sobi2 Recipe
Hello,
I am working to try and get your Sobi2 recipe to work in my system. Essentially I need is a way to display a different header on pages based on the Sobi2 category that the user is currently in. From what I understand, the metamod recipe should do exactly that. Below is the recipe I am using to try and get module 772 to display on sobi category 2. Any suggestions why it is not working?
if ($option == 'com_sobi2') {
if ( JRequest::getVar( 'sobi2Task' ) == 'sobi2Details') {
$sobi2Id = JRequest::getVar( 'sobi2Id' );
$query = 'SELECT c.name from #__sobi2_cat_items_relations r
LEFT JOIN #__sobi2_categories c on r.catid = c.catid
WHERE r.itemid = ' . $db->quote($db->getEscaped( $sobi2Id ));
$db->setQuery( $query );
$res = $db->loadResultArray();
$mods = array();
if ( array_search('2', $res) !== false ) $mods[] = 772;
return $mods;
}
}
Thanks - and also as a reference here is what I have done:
1) Created module 772 - set it to display on No Pages, but the module is enabled
2) Created metamod and set it to the position I would like module 772 to display in
3) Set the metamod to display on all pages.
4) entered the code in the PHP box
5) saved. and cannot get it to display.
Am I missing something? Thank you so much for the help!
-Matt
Re: Help with standard Sobi2 Recipe
Hi Matt,
thanks for including all that info - it definitely makes it easier to diagnose!
The only problem here is that the SQL query is returning the category names, rather than the ids, and in the "if" line, you are checking for a category id.
So, you can either change that line to query for the actual category name, e.g.:
if ( array_search('Chinese', $res) !== false ) $mods[] = 772;
Or, you can change the query to return category ids instead of names. This also simplifies the query:
$query = 'SELECT r.catid from #__sobi2_cat_items_relations r
WHERE r.itemid = ' . $db->quote($db->getEscaped( $sobi2Id ));
Cheers,
Stephen
Re: Help with standard Sobi2 Recipe
Hi there.
I tried the same recipe, because i need to do the same exact thing, but I can t manage. Can you please tell me where is the error?
if ($option == 'com_sobi2') {
if ( JRequest::getVar( 'sobi2Task' ) == 'sobi2Details') {
$sobi2Id = JRequest::getVar( 'sobi2Id' );
$query = 'SELECT c.catid from #__sobi2_cat_items_relations r
LEFT JOIN #__sobi2_categories c on r.catid = c.catid
WHERE r.itemid = ' . $db->quote($db->getEscaped( $sobi2Id ));
$db->setQuery( $query );
$res = $db->loadResultArray();
$mods = array();
if ( array_search('2', $res) !== false ) $mods[] = 67;
return $mods;
}
}
Re: Help with standard Sobi2 Recipe
Try this:
Code:
if ($option == 'com_sobi2') {
if ( JRequest::getVar( 'sobi2Task' ) == 'sobi2Details') {
$sobi2Id = JRequest::getVar( 'sobi2Id' );
$query = 'SELECT r.catid from #__sobi2_cat_items_relations r
WHERE r.itemid = ' . $db->quote($db->getEscaped( $sobi2Id ));
$db->setQuery( $query );
$res = $db->loadResultArray();
$mods = array();
if ( array_search('2', $res) !== false ) $mods[] = 67;
return $mods;
}
}
- Index
- » MetaMod
- » MetaMod General Support
- » Help with standard Sobi2 Recipe
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5944
- Posts this week:
- 2
- User Info:
- Total Users:
- 7660
- Newest User:
- marino9885
- Members Online:
- 0
- Guests Online:
- 168
- 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