Skip to content

Instantly share code, notes, and snippets.

@ezy
Last active August 29, 2015 13:57
Show Gist options
  • Save ezy/9821535 to your computer and use it in GitHub Desktop.
Save ezy/9821535 to your computer and use it in GitHub Desktop.
Drupal 7 cheatsheet
<!-- Print a template path -->
<?php print base_path(); ?>
<!-- Print a node in a page.tpl -->
<?php
$nid = 99999999;
$node = node_load($nid);
$nodeView = node_view($node);
print drupal_render($nodeView);
?>
<!-- Print a block in a page.tpl -->
<?php
$block = module_invoke('nodeblock', 'block_view', '99999999');
print render($block['content']);
?>
<!-- Print a view in a page.tpl -->
<?php
$viewName = 'view_name_here';
print views_embed_view($viewName);
?>
<!-- Print user fields in a page.tpl -->
<?php global $user;
$user_fields = user_load($user->uid);
$aboutuser = $user_fields->field_about_user['und']['0']['value'];
print $aboutuser;
?>
<!-- Print render field in a page.tpl -->
<?php print render($content['field_name_here']); ?>
<!-- PInclude header or footer block page.tpl -->
<?php include './'. path_to_theme() .'/templates/block--footer.tpl.php';?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment