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.

 

Display module on mtree search!

Display module on mtree search!

Hello,

I have a bussines mtree directory, and want to use metamod display varius modules only when the user made a search (from mt-search). so i need metamod to deliver modules based on user search keyword.

For the part of delivering modules based on keyword i use the metamod receipe and works like a charm.

My problem is there, that the module appear on all directory and if metamod find in the "content" the given keyword.. then will appear the module.

So i need this only at mosets search results.

What i have done until now:

I have two metamod in module manager, "Metamod1" & "Metamod2".
At "Metamod1" i have inserted the "based on keyword receipe" and at "Metamod2" i have inserted this receipe (based on advanced debuger).

Code:

if ( 

$option == 'com_mtree'
and $Itemid == '100055'
and JRequest::getVar('cat_id') == 0 /*!*/
and JRequest::getVar('limitstart') == 0 /*!*/
and JRequest::getVar('limit') == '10' /*!*/
and JRequest::getVar('task') == 'search' /*!*/
and JRequest::getVar('searchword') == 'search-keyword-provided-by-user' /*!*/
and JRequest::getVar('format') == 'html' /*!*/
) return xxx; /* replace XXX with the module ID or position to display */

The

Code:

return xxx;

have the metamod1 module ID.

Is there anyway to appear the

Code:

return xxx;

of metamod2 on any search keyword provided by user, and after that the metamod1 will do the job.

Code:

and JRequest::getVar('searchword') == 'search-keyword-provided-by-user' /*!*/

Thank you!

gdi
Beginner Modder
ranks
useravatar
Offline
12 Posts
Administrator has disabled public posting

Re: Display module on mtree search!

Hi gdi,

Yes, it looks like it's going to be easy to detect that keyword and make decisions based on it.

e.g. you could set up a MetaMod such that when the user searches for the term "widget", module A is shown, and if the user searches for "wombat", module B is shown, etc.

Here's how I would structure this in PHP:

Code:

if ( 

$option == 'com_mtree'
and JRequest::getVar('task') == 'search'
and JRequest::getVar('format') == 'html'
) {
  $word = JRequest::getVar('searchword');
  if ($word != '') {
    if (false !== stripos($word, 'widget')) return XXX;
    if (false !== stripos($word, 'wombat')) return YYY;
    if (false !== stripos($word, 'baz')) return ZZZ;
    // etc...
    // don't forget to replace XXX,YYY,ZZZ with the correct
    // module ids to return for each keyword.
  }
}

The only "gotcha" with this code is that it will find the chosen words as any substring of the search term. So if  you are detecting "view" and the user searches for "interview" then this will trigger the module, and this may not be what you want. On the other hand this depends on the exact words/phrases you want to detect and it may not be a problem for you.

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: Display module on mtree search!

Thank you for your help!

This receipe works as you said. But how can i appear a module no matter what the keyword would be ?

I can not assign a metamod at mtree search directory. If i get a way to assign a module into the mtree search, then is easy for me (thanks to your receipe) to handle the keyword matter.

Thank you again

gdi
Beginner Modder
ranks
useravatar
Offline
12 Posts
Administrator has disabled public posting

Re: Display module on mtree search!

Do you want it to appear when you simply go to the search page, or only after you've actually done a search?

What does MetaMod debug mode show in each case?

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: Display module on mtree search!

I want to appear when i simply go to the search page, and dont matter the user keyword.

this is the advanced debuger output without any search.

Code:

 if ( 

$option == 'com_mtree'
and $Itemid == '100055'
and JRequest::getVar('cat_id') == 0 /*!*/
and JRequest::getVar('limitstart') == 0 /*!*/
and JRequest::getVar('limit') == '10' /*!*/
and JRequest::getVar('task') == 'search' /*!*/
and JRequest::getVar('searchword') == '' /*!*/
) return XXX;

And this is the output of the advanced debuger after i made a search.

Code:

 if ( 

$option == 'com_mtree'
and $Itemid == '100055'
and JRequest::getVar('cat_id') == 0 /*!*/
and JRequest::getVar('limitstart') == 0 /*!*/
and JRequest::getVar('limit') == '10' /*!*/
and JRequest::getVar('task') == 'search' /*!*/
and JRequest::getVar('searchword') == 'my search' /*!*/
and JRequest::getVar('format') == 'html' /*!*/
) return XXX;

If i assign a metamod in the without search, then will not apear if i made a search.(and the reverse).

Regards

gdi
Beginner Modder
ranks
useravatar
Offline
12 Posts
Administrator has disabled public posting

Re: Display module on mtree search!

Ok, this will do what you want:

Code:

if ( 

$option == 'com_mtree'
and JRequest::getVar('task') == 'search'
) return XXX;
// replace XXX with module id to show on search page

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: Display module on mtree search!

:DDDD

yes it make what i want.

Thanks!

gdi
Beginner Modder
ranks
useravatar
Offline
12 Posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1685
Total Polls:
6
Total Posts:
5912
Total Posts Today:
4
User Info:
 
Total Users:
11504
Newest User:
toko solo
Members Online:
0
Guests Online:
173

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