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.

 

Mixing two recipes

Mixing two recipes

Hi,
I found the recipe page...
(http://www.metamodpro.com/metamod/recip … obi2-pages)

...which is great! And was having trouble mixing the two...
1) Detect the category when viewing a list of items in that category
2) SOBI2 search page

...so that I can show relevant modules when a specific category is returned via the search.

I tried...
if ($option == "com_sobi2" and JRequest::getVar('sobi2Task') == 'search') and ($catid = JRequest::getVar('catid') != '' ){
if ( $catid == 14 ) return 34; /* replace 14 with module to show for category 34 */
  if ( $catid == 38 ) return 91; /* replace 38 with module to show for category 91 */
}

...but to no avail.

Little help please. Thanks.
Ian

smithian
Beginner Modder
ranks
useravatar
Offline
9 Posts
Administrator has disabled public posting

Re: Mixing two recipes

Hi Ian,

could you possibly turn on MetaMod advanced debug mode, then do a search in the front-end, and post the results from the MetaMod debug text? I think that might help me understand what you're trying to achieve.

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: Mixing two recipes

Hi,
here's the advanced debug - Ian

Place a search advertisement
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 == '64'
and JRequest::getVar('sobiCid') == '0'
and JRequest::getVar('sobi2Task') == 'search'
and JRequest::getVar('sobi2Search') == 'Search ...'
and JRequest::getVar('searchphrase') == 'any'
and JRequest::getVar('search') == 'Search'
and JRequest::getVar('reset') == '2'
and JRequest::getVar('lang') == 'en'
and JRequest::getVar('SobiCatSelected_0') == '0'
) return XXX; /* replace XXX with the module ID or position to display */
MetaMod debug info:
Module ID: 95
$option: com_sobi2
$view:
$id:
$Itemid: 64
$timezone: Etc/GMT+0
$language: en-au
$language_code: en
$language_region: au

Parse error: syntax error, unexpected T_LOGICAL_AND in /home/ourgaywe/public_html/modules/mod_metamod/helper.php(558) : eval()'d code on line 1
Including modules:

smithian
Beginner Modder
ranks
useravatar
Offline
9 Posts
Administrator has disabled public posting

Re: Mixing two recipes

Hi Ian,

first up, the error you are getting is because you're missing a closing ")". Try it this way:

if ($option == "com_sobi2" and JRequest::getVar('sobi2Task') == 'search' and ($catid = JRequest::getVar('catid') != '' )){
  if ( $catid == 14 ) return 34; /* replace 34 with module to show for category 14 */
  if ( $catid == 38 ) return 91; /* replace 91 with module to show for category 38 */
}

However, that only fixes the syntax. Judging by the debug code you sent, there's no "catid" parameter in the request, so that part of it is not going to work.

When I tested out the searching on my test site, the results are done in Ajax, so there's no page refresh, and therefore the modules don't get a chance to regenerate. Perhaps yours is set up differently to mine though.

I took a look at the category dropdown in the search and see that it has a form name of "SobiCatSelected_0", so perhaps try this variant of your recipe:

if ($option == "com_sobi2" and JRequest::getVar('sobi2Task') == 'search' and ($catid = JRequest::getVar('SobiCatSelected_0') != '' )){
  if ( $catid == 14 ) return 34; /* replace 34 with module to show for category 14 */
  if ( $catid == 38 ) return 91; /* replace 91 with module to show for category 38 */
}

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: Mixing two recipes

Thanks,
it's working but only showing the first module so I dont' know if the second 'if' statement is malformed or being ignored.

if (
$option == 'com_sobi2'
and $Itemid == '64'
and JRequest::getVar('sobiCid') == '38'
and JRequest::getVar('sobi2Task') == 'search'
and JRequest::getVar('sobi2Search') == 'Search ...'
and JRequest::getVar('searchphrase') == 'any'
and JRequest::getVar('search') == 'Search'
and JRequest::getVar('reset') == '2'
and JRequest::getVar('lang') == 'en'
and JRequest::getVar('SobiCatSelected_1') == '38'
and JRequest::getVar('SobiCatSelected_0') == '4'
) return XXX; /* replace XXX with the module ID or position to display */
MetaMod debug info:
Module ID: 95
$option: com_sobi2
$view:
$id:
$Itemid: 64
$timezone: Etc/GMT+0
$language: en-gb
$language_code: en
$language_region: gb
Including modules: 34

Getting closer,
Ian

smithian
Beginner Modder
ranks
useravatar
Offline
9 Posts
Administrator has disabled public posting

Re: Mixing two recipes

Hi Ian,

do you my any chance have 34 in the "Quick module id include" box? If so, you need to remove it (and anything else from that box).

This is because module ids in that box get included automatically, whether or not the PHP box returns anything. And judging by the debug output from above, and the PHP code you were using, there's no way that the PHP code could have returned "34".

I also note that the search function is sending through category ids on SobiCatSelected_0 and SobiCatSelected_1 -- therefore you need to check for both.

e.g.

if ( $option == "com_sobi2"
  and JRequest::getVar('sobi2Task') == 'search'
  and ( $catid0 = JRequest::getVar('SobiCatSelected_0') ) != '' ) {
  $catid1 = JRequest::getVar('SobiCatSelected_1');
  if ( $catid0 == 14 or $catid1 == 14) return 34;
  if ( $catid0 == 38 or $catid1 == 38) return 91;
}

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: Mixing two recipes

Hi and thanks for persisting. I did vary the category selected to check for either but not both.
The Quick id isn't on and the new code you provide shows the debug in the right place but not the reference modules;

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 == '64'
and JRequest::getVar('sobiCid') == '14'
and JRequest::getVar('sobi2Task') == 'search'
and JRequest::getVar('sobi2Search') == 'Search ...'
and JRequest::getVar('searchphrase') == 'any'
and JRequest::getVar('search') == 'Search'
and JRequest::getVar('reset') == '2'
and JRequest::getVar('lang') == 'en'
and JRequest::getVar('SobiCatSelected_0') == '3'
) return XXX; /* replace XXX with the module ID or position to display */
MetaMod debug info:
Module ID: 95
$option: com_sobi2
$view:
$id:
$Itemid: 64
$timezone: Etc/GMT+0
$language: en-gb
$language_code: en
$language_region: gb
Including modules:

hmmm. I'll keep trying with your new code snippet.

Thanks,
Ian

smithian
Beginner Modder
ranks
useravatar
Offline
9 Posts
Administrator has disabled public posting

Re: Mixing two recipes

Going only on the example you just posted, and based on the PHP that I last sent (which you may have changed), it's showing expected behaviour: the search appears to be for category 3, and that's not one of the categories you were testing for.

If you're using exactly the snippet that I sent, can you try searching on category 14 or 38, and see what it comes up with?

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: Mixing two recipes

This is interesting and something I hadn't tried before. Using your most recent snippet (which is fine because I only what to test for ('SobiCatSelected_1')at the moment);
-----------------------------------------------------------------------
if ($option == "com_sobi2" and JRequest::getVar('sobi2Task') == 'search' and ($catid = JRequest::getVar('SobiCatSelected_0') != '' )){
  if ( $catid == 14 ) return 34; /* replace 34 with module to show for category 14 */
  if ( $catid == 38 ) return 91; /* replace 91 with module to show for category 38 */
}
----------------------------------------------------------------------

The first search attempt fails to find ('SobiCatSelected_1') == '14'
but keeping the selections and searching a second time works! The debug reveals that this is the case (i.e. ('SobiCatSelected_1') == '14' doesn't appear in the debug initially). I'll try an 'in/and/' for both 'sobiselected_' to see if that prompts a check for the second category.

Ian

smithian
Beginner Modder
ranks
useravatar
Offline
9 Posts
Administrator has disabled public posting

Re: Mixing two recipes

Here's the first and second sets of debugs. The only change made is that I've hit the 'search' but (with the same categories selected) a second time.

1.
if (
$option == 'com_sobi2'
and $Itemid == '64'
and JRequest::getVar('sobiCid') == '14'
and JRequest::getVar('sobi2Task') == 'search'
and JRequest::getVar('sobi2Search') == 'Search ...'
and JRequest::getVar('searchphrase') == 'any'
and JRequest::getVar('search') == 'Search'
and JRequest::getVar('reset') == '2'
and JRequest::getVar('lang') == 'en'
and JRequest::getVar('SobiCatSelected_0') == '3'
) return XXX; /* replace XXX with the module ID or position to display */
MetaMod debug info:
Module ID: 95
$option: com_sobi2
$view:
$id:
$Itemid: 64
$timezone: Etc/GMT+0
$language: en-gb
$language_code: en
$language_region: gb
Including modules:

2.
if (
$option == 'com_sobi2'
and $Itemid == '64'
and JRequest::getVar('sobiCid') == '14'
and JRequest::getVar('sobi2Task') == 'search'
and JRequest::getVar('sobi2Search') == 'Search ...'
and JRequest::getVar('searchphrase') == 'any'
and JRequest::getVar('search') == 'Search'
and JRequest::getVar('reset') == '2'
and JRequest::getVar('lang') == 'en'
and JRequest::getVar('SobiCatSelected_1') == '14'
and JRequest::getVar('SobiCatSelected_0') == '3'
) return XXX; /* replace XXX with the module ID or position to display */
MetaMod debug info:
Module ID: 95
$option: com_sobi2
$view:
$id:
$Itemid: 64
$timezone: Etc/GMT+0
$language: en-gb
$language_code: en
$language_region: gb
Including modules: 34

--------------------------------
'SobiCid' seems to make it through both attempts so that make be a way forward. weird.

Ian

smithian
Beginner Modder
ranks
useravatar
Offline
9 Posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5933
Posts this week:
3
User Info:
 
Total Users:
4401
Newest User:
jason59312
Members Online:
0
Guests Online:
100

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