4

I'm working on extending the external_entries plugin to support a SQL LIKE clause, using the "searchlike" param that was mentioned here:

As and example if I wanted to find all rows of an external table in that had a date of 2013 I would use the param searchlike:date="2013%".

Is there a way to use fetch_param (or something akin to it) with a param name that you only know the beginning of?

1 Answer 1

5

The full array of tag params is stored at $EE->TMPL->tagparams. So you can grab them like so:

// Get the EE instance
$EE = get_instance();

// Get all of the current tag params
$all_params = $EE->TMPL->tagparams;

From there you can loop through and find all of the params that begin with “search:” like this:

// Find all of the search:xyz params
$search_params = array();

foreach ($all_params as $name => $value)
{
    // Does this param name start with "search:"?
    if (strncmp($name, 'search:', 7) === 0)
    {
        // Chop off "search:" and save it
        $search_target = substr($name, 7);
        $search_params[$search_target] = $value;
    }
}
2
  • Exactly how I do it. Jan 12, 2013 at 1:32
  • Cool, that's perfect!
    – diemer
    Jan 13, 2013 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.