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.

 

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

MattJLehr
Beginner Modder
ranks
useravatar
Offline
5 Posts
Administrator has disabled public posting

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

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

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;
  }
}

verzevoul
Beginner Modder
ranks
useravatar
Offline
1 Posts
Administrator has disabled public posting

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;
  }
}

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

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5933
Posts this week:
4
User Info:
 
Total Users:
4379
Newest User:
coates7891
Members Online:
2
Guests Online:
232


Forum Legend:

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