D7

Add Js

Submitted by shiv on Sun, 11/20/2016 - 11:30

Add a JS file to head from Module

  <?php /*  This will add a JS file to your head (specifically the $scripts variable in page.tpl.php)  */ 
drupal_add_js(drupal_get_path('type', 'module_or_theme_Name') . '/my_module.js');
?>

Adding a CDN asset to drupal theme

Submitted by shiv on Sun, 11/06/2016 - 10:28

Add CDN/External css

  <?php /* Comment goes here */
 function beginning_preprocess_html(&$variables) {  drupal_add_css('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css', array('type' => 'external'));
}
?>

Get node type in template file

Submitted by shiv on Sun, 10/30/2016 - 16:34

<?php /* new code block */

   if (arg(0) == 'node' && is_numeric(arg(1))) {
   $node = node_load(arg(1));
   if ($node && $node->type == 'machin_name_of_node_type') {
   print '<h2 class="title comment-form review-form">Add new review</h2>';
   }
   else {print '<h2 class="title comment-form">Add new Comment</h2>';}
  }
  /* End of new code block */
  ?>

Add node into node

Submitted by shiv on Fri, 09/16/2016 - 14:34

Add full node into node

 
<?php
$page = node_show(node_load(7));
print render($page);
?>
 

or
$displaynode this variable should be uniq And adjust node_load() number as per node id.

Subscribe to D7

Sample blackbox block

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas non porta odio, id mattis erat.

Nam sed tincidunt eros. Donec a venenatis odio, vitae commodo sem. Vivamus ullamcorper pellentesque erat, in adipiscing tortor scelerisque sit amet. Nulla pulvinar urna magna. Vivamus a ipsum lorem. Etiam adipiscing pulvinar lorem.