Skip to content

Instantly share code, notes, and snippets.

@dawehner
Created May 19, 2009 17:16
Show Gist options
  • Save dawehner/114230 to your computer and use it in GitHub Desktop.
Save dawehner/114230 to your computer and use it in GitHub Desktop.
<?php
// load the fields into an array so we can easily grab any piece we want
// 0 - image URL
// 1 - HTML link to node
// 2 - external link
//print count($fields);
foreach ($fields as $id => $field):
$item[] = $field;
endforeach;
// strip HTML from default output
$imgURL = preg_replace('/<\/?.*?>/','',$item[0]->content);
$resourceURL = preg_replace('/<a href="(.*?)">.*?<\/a>/','$1',$item[1]->content);
// banner ad output
if ($item[2]->content) {
$imgTag = "<a href='{$item[2]->content}' target='_blank'><img src='$imgURL' alt='' /></a>";
}
elseif ($resourceURL) {
$imgTag = "<a href='$resourceURL' target='_blank'><img src='$imgURL' alt='' /></a>";
}
?>
<div class="banner-ad">
<div class="caption">advertisement</div>
<?php print $imgTag ?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment