Created
September 14, 2012 11:55
-
-
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
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
/* | |
* 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> |
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
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]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.