Last active
August 29, 2015 13:57
-
-
Save ezy/9821535 to your computer and use it in GitHub Desktop.
Drupal 7 cheatsheet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Print a template path --> | |
<?php print base_path(); ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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