Currently, it seems like the module does not allow us to embed our own variables as implied in the Javascript configuration variabledocs. I was wondering if it would be viable to incorporate a hook to, in the meantime, provide us with this capability on the code level (simply by overwriting the initial array).
Usage:
/**
* Implements hook_change_disqus_thread
*/
function foo_change_disqus_thread($disqus) {
return array(
'url' => 'http://www.example.com,
'identifier' => 123,
'title' => 'Hello World,
'domain' => $disqus['domain'],
);
}
Comments
Comment #1
pcho commentedCorrected patch
Comment #2
skruf commentedThis fails if more than one module implements the hook as module_invoke_all merges all the results recursively into one array. The array structure then changes and is incompatible with the rest of the code eg. $disqus['url'] is now an array rather than a string.
An alter hook would be more appropriate. Here is a patch for this.
Comment #3
slashrsm commentedIs there anything that can be achieved with this hook and cannot be achieved with hook_js_alter()?
Comment #4
hugronaphor commented@slashrsm Your last question probably blocked everyone and they silently are using this patch.
Yes you can achieve the same things by hook_js_alter(), but it's easier, cleaner and better to do some Disqus variable re-write in a hook like this.
This is my choice: https://www.drupal.org/files/disqus-add_alter_hook_js_variables-1419562-...
Comment #5
damienmckennaI think the API should be different.