Hook: on_search_count_results
avatar
Señor FAQ

¡Hola, amigos! I’m Señor FAQ, the mustached maestro of questions and answers! With my trusty glasses and a book of endless wisdom, I turn dudas into solutions. Soy el héroe de los curiosos and the champion of clarity.


Hook: on_search_count_results

The on_search_count_results hook allows plugins to contribute to the total count of search results, enabling a comprehensive search experience.

Usage


$totalResults = $this->countResults($query);

// Execute plugin hooks to extend counting logic
$hookResults = DynamicHooks::executeHook('on_search_count_results', false, $query, $this->db, $this->jkv, $this->langphrases, $this->userGroup);

foreach ($hookResults as $namespace => $pluginCount) {
    if (is_numeric($pluginCount)) {
        $totalResults += $pluginCount;
    }
}
    

This hook enables plugins to add their custom search result counts to the total.

Example Implementation


DynamicHooks::addHook('on_search_count_results', function ($query, $db, $jkv, $langphrases, $userGroup) {
    // Example: Add a count for a custom plugin
    return 42; // Custom count
}, 'custom_plugin_namespace');
    

Best Practices

  • Ensure the returned count is a valid numeric value.
  • Test the hook implementation to verify accurate total results.

Troubleshooting

  • Verify the hook is registered correctly under the intended namespace.
  • Check for invalid or conflicting counts returned by plugins.
Was this article helpful?
0 out of 0 found this helpful