There is a simple way to do this in Drupal 7, using the function drupal_add_js and creating an array with the data we want to make accessible:
[prism:php] $settings = array ( 'foo' => 'bar', 'name' => 'john', ); drupal_add_js( array ("my_module" => $settings), 'setting'); [/prism:php] Notice that we are using the 'setting' parameter on drupal_add_js
This way we indicate to the function that we are passing settings.
[prism:php] var name = Drupal.settings['my_module']['name']; [/prism:php]
Drupal is one of the most versatile CMS today and the one used to build many of the web pages that we visit every day. According to the definition given on its official website, “Drupal is a content management software. It is used to create many of the websites and applications of daily use”.
With a flexible and modular system, Drupal has managed to penetrate the taste of developers when they must design a web page that is easy to use for the common user.