Hi Folks,
I've added JavaScript/AJAX to a node display which is managed by Display Suite. Consequently, I've added:
drupal_add_library('system', 'drupal.ajax'); drupal_add_js(drupal_get_path('module', 'music_display') . '/music_display.js');
to ds-2col-fluid--node-music.tpl.php This works well because the JavaScript is only loaded for this content-type, but it only works because I sub-themed Bartik on this development site. On the production site, I don't know what theme the designers will use, so I want to move these two line to a module.
How do I create the same qualification, meaning make the above two calls only in the case where Drupal, in the guise of Display Suite, is displaying the "Music" node?
Chris.
You could probably implement hook_node_view in a custom module. Which will operate on all views of a node. Test on the type of the node variable and add the appropriate .js files?
https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hoo...
Dave
From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Chris Miller Sent: Wednesday, November 20, 2013 10:03 AM To: support@drupal.org Subject: [support] Avoid sub-theme
Hi Folks,
I've added JavaScript/AJAX to a node display which is managed by Display Suite. Consequently, I've added:
drupal_add_library('system', 'drupal.ajax'); drupal_add_js(drupal_get_path('module', 'music_display') . '/music_display.js');
to ds-2col-fluid--node-music.tpl.php This works well because the JavaScript is only loaded for this content-type, but it only works because I sub-themed Bartik on this development site. On the production site, I don't know what theme the designers will use, so I want to move these two line to a module.
How do I create the same qualification, meaning make the above two calls only in the case where Drupal, in the guise of Display Suite, is displaying the "Music" node?
Chris.
From: "David Metzler" metzlerd@evergreen.edu To: "support@drupal.org" support@drupal.org Sent: Wednesday, November 20, 2013 10:12:56 AM Subject: Re: [support] Avoid sub-theme
You could probably implement hook_node_view in a custom module. Which will operate on all views of a node. Test on the type of the node variable and add the appropriate .js files?
https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hoo...
Hi Dave,
I've reviewed api.drupal.org, and I agree with you that this is a good approach. Thanks very much for the help,
Chris.