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

How to include search params in plugin with TMPL->tagparams

Development and Programming

alldayeveryday's avatar
alldayeveryday
3 posts
11 years ago
alldayeveryday's avatar alldayeveryday

I’m building a custom plugin tag pair which returns channel entries. Almost everything seems to be working: I set the TMPL->tagparams array to my custom params, instantiate a new Channel(), and return its entries.

I’m searching a “classes” channel where entries have a “weekday” custom field with values like “Monday”, “Tuesday”, etc. In the case, I want to return the first 5 classes on Mondays:

$this->EE->TMPL->tagparams = array(
  'channel' => 'classes',
  'limit' => '5',
  'search:weekday' => '=Monday'
);
$channel = new Channel();
return $channel->entries();

However, EE seems to be ignoring the search:weekday param. It’s returning the right channel and enforcing the limit, but it’s returning all results, not just results with “Monday” for their “weekday” custom field. Should search params work in a plugin like this, and if so, how?

(Also posted on EE.stackexchange)

       
alldayeveryday's avatar
alldayeveryday
3 posts
11 years ago
alldayeveryday's avatar alldayeveryday

Over on Stack Exchange, Low clued me into the fact that search params use a different TMPL array, search_fields instead of tagparams. This did the trick:

ee()->TMPL->search_fields['weekday'] = '=Monday';
       

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.