Skip to content

Instantly share code, notes, and snippets.

@carwin
Created September 14, 2012 11:55
Show Gist options
  • Save carwin/3721521 to your computer and use it in GitHub Desktop.
Save carwin/3721521 to your computer and use it in GitHub Desktop.
Drupal 7: Remove the link on a user-picture entirely and render a region in node.tpl.php
/*
* Render the new user picture
*/
<?php print '<div class="user-picture"><img src="' . $user_picture . '" /></div>'; ?>
/*
* Render the now-available 'below_content' region
* under the content or wherever you want.
*/
<div class="content"<?php print $content_attributes; ?>>
<?php
// We hide the comments and links now so that we can render them later.
hide($content['comments']);
hide($content['links']);
print render($content);
print render($below_content);
?>
</div>
function foo_preprocess_node(&$variables) {
/*
* Pass a region called 'below_content'
* as a region to node.tpl.php
*/
if($blocks = block_get_blocks_by_region('below_content')) {
$variables['below_content'] = $blocks;
}
/*
* Take the user picture string and regex
* the url into $matches. Replace the old
* string with just the url to pass to node.
*/
$string = $variables['user_picture'];
preg_match_all('#\bhttps?://[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/))#', $string, $match);
if($picture = $variables['user_picture']) {
$variables['user_picture'] = $match[0][0];
}
}
@carwin
Copy link
Author

carwin commented Sep 14, 2012

It would be nice if gists would let you choose the order that files get displayed in. I wrote this thinking people would look at template.php first, so do that if you're confused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment