Here is another way to add the external .js file .
$external_js = 'http://www.example.com/a.js';
drupal_add_js('document.write(unescape("%3Cscript src=\''. $external_js . '\' type=\'text/javascript\'%3E%3C/script%3E"));', 'inline');
Done =)
Previous Post: Drupal – Load External Javascript using drupal_add_js() @ 1
Reference: Web Design by Tim Wooten – Load external js file in Drupal 6
If you want to include external .js file in your custom module , create the following file.
external.js
(function ($) {
Drupal.behaviors.myModule = function(context) {
var externalScript = $('<script></script>').attr('type','text/javascript').attr('src', 'http://example.org/example.js');
$('body').append(externalScript);
}
}(jQuery));
Continue reading Drupal – Load External Javascript using drupal_add_js() @ 1 →
Again, i will use the custom module i have created in
Drupal – Introduction to Drupal Theming @ 3
This time we add a custom form called ykyuen_greeting_form in the preprocess function.
Continue reading Drupal – Call Javascript after form submission →
Previously, we talked about how to get the number of nodes of a specific term .
Drupal – Get Number of node of Taxonomy Term by Term ID
How about if i want to get the number of nodes under a specific parent term ? Unfortunately, there is no such function . so i try to get that number by SQL . Here is the PHP code .
Continue reading Drupal – Get the Number of nodes under a Parent Term →
Yesterday we talked about setting up a Apache Solr for Drupal 7 site search .
Drupal 7 – Setup Apache Solr for site search
If you want to have more control on the search index with flexible search pages. You can consider the Search API and Search API Apache Solr .
Continue reading Drupal 7 – Apache Solr and Search API →
1. Download Apache Solr 3.4 and extract it.
2. Also download the Drupal Apache Solr Search Integration module.
3. In the extracted Solr folder. go to ./example/solr/conf .
4. Backup the following files by rename them. Continue reading Drupal 7 – Setup Apache Solr for site search →
Next: Drupal 7 – Add the latest jQuery on your Drupal 7 without conflicts
The jQuery Update module allows us to update the Drupal 6 core jQuery to 1.3.2 . This is definitely not enough for many 3rd party jQuery libraries. If you want to add the latest jQuery without affecting the core script, you can try the following approach which makes use of the jQuery.noConflict() and it is originally written by gala4th in his blog THERE IS NO PLACE LIKE 127.0.0.1 .
Ok, now we want to add the new jQuery for a specific content. Let’s follow the custom module we created in Continue reading Drupal – Add Extra jQuery Library →
When you trying to set the redirection as mentioned in
Drupal – Redirect after Form Submission @ 2
Drupal will automatically encoded the path stored in $form_state[‘redirect’] . For example:
$form_state['redirect'] = 'user/4/bags?bagid=17';
// the output path will be user/4/bags%3Fbagid%3D17
Continue reading Drupal – Redirect after Form Submission @ 3 →
We can make a redirection after form submission using hook_form_alter() as mentioned in
Drupal – Redirect after Form Submission @ 1
But it does not work for some forms such as the user_login form. In that case, we have to unset the $form[‘action’] and add an extra form submission function as follow. Continue reading Drupal – Redirect after Form Submission @ 2 →
Use the hook_form_alter() for redirection after form submission . Continue reading Drupal – Redirect after Form Submission @ 1 →
Posts navigation
Dream BIG and go for it =)