We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Search Keyword in Plugin

Development and Programming

srikanth aetukuri's avatar
srikanth aetukuri
40 posts
14 years ago
srikanth aetukuri's avatar srikanth aetukuri

Hello, I’m trying to make a plugin for getting the search results assigned categories with the result count. I’m stuck at using the search keyword tag in my plugin.

{exp:search_results_categories search_term="{exp:search:keywords}"}

 <-- plugin  o/p-->                                    

{/exp:search_results_categories}

Can I use like mentioned ?

$this->EE->TMPL->fetch_param('search_term')

displays same hash code everytime for diff searches.

Srikanth

Moved to Development and Programming by Moderator

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
14 years ago
Sue Crocker's avatar Sue Crocker

Hi, srikanth. Actual programming questions normally go into the Devloper Forum.. moving there for additional community support.

       
srikanth aetukuri's avatar
srikanth aetukuri
40 posts
14 years ago
srikanth aetukuri's avatar srikanth aetukuri

Thanks Sue. Can somebody help me here ?

       
Focus Lab Dev Team's avatar
Focus Lab Dev Team
1,129 posts
14 years ago
Focus Lab Dev Team's avatar Focus Lab Dev Team

Hi Srikanth,

You can do this but you need to add 1 more parameter to your plugin tag. You need to tell EE to parse the {exp:search:keywords} tag BEFORE it parses your plugin parameters and tags. Since EE parses the tags as they’re encountered in the template, your plugin is getting parsed FIRST which means it’s literally using “{exp:search:keywords}” as the value of your parameter.

The parameter you add is parse=”inward” which makes the exp: tag get parsed first. Try this:

{exp:search_results_categories search_term="{exp:search:keywords}" parse="inward"}

 <-- plugin  o/p-->                                    

{/exp:search_results_categories}
       
srikanth aetukuri's avatar
srikanth aetukuri
40 posts
14 years ago
srikanth aetukuri's avatar srikanth aetukuri

Thanks Erik. Will try this.

       
srikanth aetukuri's avatar
srikanth aetukuri
40 posts
14 years ago
srikanth aetukuri's avatar srikanth aetukuri

Erik, even after using the above code I’m not able to fetch the value.

{exp:search_results_categories searchterm="{exp:search:keywords}" parse="inward"}

 <-- plugin  o/p-->                                    

{/exp:search_results_categories}  

$searchterm = $this->EE->TMPL->fetch_param('searchterm');
echo $searchterm;

Diplays some hash code everytime. Please help.

But

{exp:search:keywords}

ouputs the search term when used normally.

       
srikanth aetukuri's avatar
srikanth aetukuri
40 posts
14 years ago
srikanth aetukuri's avatar srikanth aetukuri
{exp:search_results_categories searchterm="{segment_1}" parse="inward"}

 <-- plugin  o/p-->                                    

{/exp:search_results_categories}

This works though. Problem with search keywords tag ?

       
srikanth aetukuri's avatar
srikanth aetukuri
40 posts
14 years ago
srikanth aetukuri's avatar srikanth aetukuri

It is working as I found some other solution. I passed the search id from the url and in plug-in queried the db for the search term for the given search id.

Thanks Erik for the help.

Srikanth

       
Focus Lab Dev Team's avatar
Focus Lab Dev Team
1,129 posts
14 years ago
Focus Lab Dev Team's avatar Focus Lab Dev Team
It is working as I found some other solution. I passed the search id from the url and in plug-in queried the db for the search term for the given search id. Thanks Erik for the help. Srikanth

Glad you found a solution and glad to help out 😊

Erik

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.