Hook: on_helpful_box_plugin_context
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_helpful_box_plugin_context

The on_helpful_box_plugin_context hook allows plugins to provide dynamic context to the helpful box feature. This is particularly useful for associating plugin-specific content, such as articles or pages, with feedback tracking mechanisms.

Usage


$hookResults = DynamicHooks::executeHook('on_helpful_box_plugin_context', false, [
    'page_id' => $page_id,
    'news_article_id' => $news_article_id,
], $jakdb, $jkv, $lang);

foreach ($hookResults as $namespace => $context) {
    if (isset($context['plugin_id']) && isset($context['plugin_item_id'])) {
        $plugin_id = $context['plugin_id'];
        $plugin_item_id = $context['plugin_item_id'];
        break; // Stop if valid plugin context is found
    }
}
    

This hook aggregates plugin-specific context and allows the helpful box to function dynamically for different types of content.

Example Implementation


$yourPluginId = $this->db->get('plugins', 'id', ['name' => 'Your_Plugin_Name']);

DynamicHooks::addHook('on_helpful_box_plugin_context', function($context) use ($plugin, $yourPluginId) {
    if (isset($context['page_id'])) {
        return [
            'plugin_id' => $yourPluginId,
            'plugin_item_id' => $plugin['id'] ?? null
        ];
    }
    return null;
}, 'your_plugin');
    

Best Practices

  • Ensure the returned context includes valid plugin_id and plugin_item_id values.
  • Use meaningful namespaces to avoid conflicts between plugins.
  • Test the context thoroughly to ensure the helpful box feature works as intended.

Troubleshooting

  • Verify that the hook is registered correctly with the intended namespace.
  • Check the $context array for missing or invalid values.
  • Use logging to debug issues with the plugin-specific context.
Was this article helpful?
0 out of 0 found this helpful