Skip to content

Instantly share code, notes, and snippets.

@yanniboi
Created November 21, 2013 16:06
Show Gist options
  • Save yanniboi/7584465 to your computer and use it in GitHub Desktop.
Save yanniboi/7584465 to your computer and use it in GitHub Desktop.
Writing a theme function and template for Instagram Block (drupal 7)
/**
* @file
* Default theme implementation of an Instagram image link.
*
* Available variables:
* - data: The entire data array returned from the Instagram API request.
* - href: The url to the Instagram post page.
* - src: The source url to the instagram image.
* - width: The display width of the image.
* - height: The display height of the image.
*/
?>
<a class="group" target="blank_" rel="group1" href="<?php print $href ?>">
<img style="float: left; margin: 0 5px 5px 0px; width: <?php print $width ?>px; height: <?php print $height ?>px;" src=" <?php print $src ?>">
</a>
/**
* Implements hook_theme().
*/
function instagram_block_theme() {
$items = array(
'instagram_block_image' => array(
'render element' => 'element',
),
);
return $items;
}
$content['children'][$post->id] = array(
'#markup' => '',
'#theme' => 'instagram_block_image',
'post' => $post,
'link' => $post->link,
'url' => $post->images->thumbnail->url,
'width' => $values['width'],
'height' => $values['height'],
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment