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.

 

Module not showing on Sobi entry page but all other recipes working ok

Module not showing on Sobi entry page but all other recipes working ok

Hi

First of all - great module, there are so many uses for this smile

I am trying to get modules to show on SOBI entry page depending on category.  I used the recipe example on your site however it is not working for me. The other recipe examples are working fine for me i.e. to show on Vcard view, to show on individual entry ID etc.

My recipe and details are below.

Recipe:

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();
    // was category 5 one of the categories? If so add mod 54
    if ( array_search( 5, $res) !== false ) $mods[] = 54;
    // was category 6 one of the tags? If so add mod 53
    if ( array_search( 6, $res) !== false ) $mods[] = 53;
    return $mods;
  }
}



Joomla 1.5.18
MetaMod 2.5
SOBI 2.9.3.1

Note: As I said other recipes are working fine, for example the one below displays fine on entry page but I want to display by category ID not entry ID:

if ( $option == "com_sobi2" and JRequest::getVar('sobi2Task') == 'sobi2Details' ) {
  $sobi2Id = JRequest::getVar( 'sobi2Id' );
  if ( $sobi2Id == 1 ) return 54; /* replace 54 with the module to use for SOBI2 item 1 */
  if ( $sobi2Id == 2 ) return 54; /* replace 54 with the module to use for SOBI2 item 2 */
  if ( $sobi2Id == 3 ) return 54; /* replace 54 with the module to use for SOBI2 item 3 */
}


Help would be very much appreciated.

Thanks

Edited By: kaizagency
21-Sep-10 23:05:34

kaizagency
Beginner Modder
ranks
useravatar
Offline
13 Posts
User info in posts
Administrator has disabled public posting

Re: Module not showing on Sobi entry page but all other recipes working ok

Regarding the second recipe - you want to detect by category id instead of by entry id. Try this:

if ( $option == "com_sobi2" and JRequest::getVar('sobi2Task') == 'sobi2Details' ) {
  $catid = JRequest::getVar( 'catid' );
  if ( $catid == 1 ) return XXX; /* replace XXX with the module to use for SOBI2 category 1 */
  if ( $catid == 2 ) return YYY; /* replace YYY with the module to use for SOBI2 category 2 */
  if ( $catid == 3 ) return ZZZ; /* replace ZZZ with the module to use for SOBI2 category 3 */
}

Regarding the first recipe - I just tried it out and it works for me. Perhaps try this variant, for debugging purposes. It should output a list of the category id numbers that the item is in:


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();
    print_r($res);
  }
}

On my test installation this shows up: "Array ( [0] => 6 )" telling me that the item I was viewing is in category 6. If it's in more than one category then you'll see the rest of them listed there too.


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

Re: Module not showing on Sobi entry page but all other recipes working ok

Hi

Thanks for the reply.  The recipe is still not working for me, strange as the other recipe is working fine on the entry page.  I did what you said and entered code to debug.  You can see the message on link provided and also pasted below (just in case I have to remove before you read this reply).

Is there supposed to be a big gap in front of "catid" because ID and task do not have this gap?

index.php?option=com_sobi2&sobi2Task=sobi2Details&__%20%20%20%20catid=5&sobi2Id=1&Itemid=24

The entry is in only one category.  What do you think is causing the problem?

Sorry I am new to this and also cannot understand PHP sad

Thank you, thank you so much for your help smile

DEBUG Message:

Page Identification
The PHP code below may be used to help MetaMod to identify the exact page that you are viewing. For help using this feature, please click here.
if (
$option == 'com_sobi2'
and $Itemid == NULL
and JRequest::getVar('sobi2Id') == '1'
and JRequest::getVar('______catid') == '5' /*!*/
and JRequest::getVar('sobi2Task') == 'sobi2Details'
) return XXX; /* replace XXX with the module ID or position to display */
Note: lines starting with "and" and ending with /*!*/ contain rules that may be optional. You may wish to leave them out.
MetaMod debug info:
Module ID: 47
$option: com_sobi2
$view:
$id:
$Itemid: 24
$timezone: default
$language: en-us
$language_code: en
$language_region: us
Array ( [0] => 8 ) Including modules:

kaizagency
Beginner Modder
ranks
useravatar
Offline
13 Posts
User info in posts
Administrator has disabled public posting

Re: Module not showing on Sobi entry page but all other recipes working ok

The link that you're giving seems to be malformed. You are giving it as this:

http://www.vacationandcuisine.com/index … ;Itemid=24

but I think it should be this:

http://www.vacationandcuisine.com/index … ;Itemid=24

Did you get that link directly off the site somewhere? If so, something has messed it up a bit.

Anyway, thanks for sending the debug output. What that tells me is that the item is in category id 8. Are you checking for that category id number in your rule? If not, then that's why it's not working.

It may seem confusing that the URL has catid=5 in it, but the item itself is apparently only in category id 8. I'm not sure why SOBI2 is doing this - perhaps it shows all items that have an "ancestor" category of 5 in it, and category 8 is a child of category 5? If so then the simplest way to do this is to check for all the ancestor categories as well as the child ones.

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

Re: Module not showing on Sobi entry page but all other recipes working ok

Thank you for helping me, it is very much appreciated.

I am getting that link directly from my browser and you are right it is showing malformed there with big gap before catid - what could be causing this do you think?

The recipe I am using includes category 8 - you can see my code below.  You are right Category 8 is a child of category 5.  Would this cause problems with the recipe I am using?  The entry is only assigned to one category though, which is 8.

if ( $option == "com_sobi2" and JRequest::getVar('sobi2Task') == 'sobi2Details' ) {
  $catid = JRequest::getVar( 'catid' );
  if ( $catid == 5 ) return 48; /* replace XXX with the module to use for SOBI2 category 5 */
  if ( $catid == 6 ) return 48; /* replace YYY with the module to use for SOBI2 category 6 */
  if ( $catid == 7 ) return 53; /* replace ZZZ with the module to use for SOBI2 category 7 */
  if ( $catid == 8 ) return 48; /* replace ZZZ with the module to use for SOBI2 category 8 */
}

Sorry I'm not sure what I am doing wrong - I got the other recipes to work ok but maybe the nested category thing is causing issues for this one?

Let me know

Thanks again for helping smile

kaizagency
Beginner Modder
ranks
useravatar
Offline
13 Posts
User info in posts
Administrator has disabled public posting

Re: Module not showing on Sobi entry page but all other recipes working ok

Ok I have noticed something - it works ok on the corrected link but not on the malformed link which is what you get when you click Destinations > Italy > and select an entry (this is what visitors would do).

I think I know what it might be.  I followed some instruction from SOBI creators to edit breadcrumbs as SOBI category is duplicated when using native joomla menus. I think this is causing the malformed URL.

I will check it now and let you know.

Thanks for your help again smile

kaizagency
Beginner Modder
ranks
useravatar
Offline
13 Posts
User info in posts
Administrator has disabled public posting

Re: Module not showing on Sobi entry page but all other recipes working ok

Ok it's not the breadcrumb hack - all works fine when clicking entry title or icon to view details view page.  The problem is the read more link, I found a code for this in the SOBI forum and this is what is causing the malformed URL. 

I know you are not from SOBI but if you do know why the read more link code below may be causing the malformed URL then it would be great if you can tell me.  You are a great Joomla master so maybe you can easily see why it could be doing this.  If not thanks again for all your help, very much appreciated smile

Your module will be very useful to my projects so I will be using and donating regularly.  Read more link code below:

  <div class="tour_readmore">
<?php
$catid = (int) sobi2Config::request($_REQUEST, 'catid', 0);
$config =& sobi2Config::getInstance();
$link = sobi2Config::sef("index.php?option=com_sobi2&sobi2Task=sobi2Details&
    catid={$catid}&sobi2Id={$id}&Itemid={$config->sobi2Itemid}");
?>
<a href="<?php echo $link ?>">View Details...</a>
  </div>

THANKS smile

kaizagency
Beginner Modder
ranks
useravatar
Offline
13 Posts
User info in posts
Administrator has disabled public posting

Re: Module not showing on Sobi entry page but all other recipes working ok

The problem is this line:

$link = sobi2Config::sef("index.php?option=com_sobi2&sobi2Task=sobi2Details&
    catid={$catid}&sobi2Id={$id}&Itemid={$config->sobi2Itemid}");

You have split this over 2 lines, therefore it is adding spaces and maybe tabs as well, inside the quotes.

Try putting it all as 1 line:

$link = sobi2Config::sef("index.php?option=com_sobi2&sobi2Task=sobi2Details&catid={$catid}&sobi2Id={$id}&Itemid={$config->sobi2Itemid}");

Or, use quotes around both parts:

$link = sobi2Config::sef("index.php?option=com_sobi2&sobi2Task=sobi2Details&"
   . "catid={$catid}&sobi2Id={$id}&Itemid={$config->sobi2Itemid}");

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

Re: Module not showing on Sobi entry page but all other recipes working ok

(note: on my browser the "all in one line" version gets split after the "?". But it should all be one line with no spaces in the part inside the quotes)

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

Re: Module not showing on Sobi entry page but all other recipes working ok

Thank you, I actually managed to figure it out just before I saw your message.  It's because I just copied and pasted the code straight from SOBI website.

Thanks again for all your help, much appreciated

kaizagency
Beginner Modder
ranks
useravatar
Offline
13 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1691
Total Polls:
6
Total Posts:
5912
Total Posts Today:
6
User Info:
 
Total Users:
11529
Newest User:
jame380003
Members Online:
0
Guests Online:
226

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