Hook: on_tags_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_tags_count_results

The on_tags_count_results hook allows plugins to contribute custom counts to the total number of tagged results.

Usage


$totalResults = $this->countTaggedResults($tag);

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

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

This hook aggregates custom tag result counts and adds them to the total.

Example Implementation


DynamicHooks::addHook('on_tags_count_results', function ($tag, $db, $jkv, $langphrases) {
    // Example: Add a count for custom tagged results
    return 15; // 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 correctly registered under the intended namespace.
  • Check for invalid or conflicting counts returned by plugins.
Was this article helpful?
0 out of 0 found this helpful