Created
August 1, 2011 09:52
-
-
Save nfreear/1117872 to your computer and use it in GitHub Desktop.
Drupal custom rotator - block
This file contains 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
<?php | |
/**Drupal rotator block - with RDFa. | |
©N.D.Freear, 20 Oct 2010. | |
*/ | |
$links = array( | |
array( | |
'text' => '<em property="dc:title">CloudEngine</em>: powering Cloudworks<i>, on Bitbucket.</i>', | |
'url'=>'http://getcloudengine.org', | |
'img'=>'https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2010/Oct/11/cloudengine-avatar2_avatar.png'), | |
array( | |
'text' => '<em property="dc:title">Moodle 2.0 for Teaching 4-9 Year Olds<i> Beginner\'s Guide</i></em>,<br /> by' | |
.' <span property="dc:creator">Nick Freear</span><i>, on <span property="dc:publisher">Packt Publishing</span></i>', | |
'url' => 'http://packtpub.com/moodle-2-0-for-teaching-4-9-year-olds-beginners-guide/book', | |
'img' => 'http://packtpub.com/sites/default/files/imagecache/productview/3289os_mockupcover_bg.jpg', | |
'isbn'=> '978-1-84951-328-9' ), | |
array( | |
'text' => '<em property="dc:title">Seeing the World My Way</em>,<br /> by <span property="dc:creator">Tony Giles</span><i>, on Amazon.</i>', | |
'url'=>'http://www.amazon.co.uk/Seeing-World-Way-Tony-Giles/dp/1906236380/', | |
'img'=>'http://ecx.images-amazon.com/images/I/51W10zgXIPL._SL500_AA300_.jpg', | |
'isbn'=>'9781906236380'), | |
/*array( | |
'text'=>'International Stammering Awareness Day, 22 October<i> 2010, on Cloudworks.</i>', | |
'url' =>'http://cloudworks.ac.uk/cloud/view/4697', | |
'img' =>'http://www.mnsu.edu/comdis/isad13/isad13-2.jpeg'),*/ | |
array( | |
'text'=>'British Stammering Association<i>, donate for change.</i>', | |
'url' =>'http://stammering.org/change', | |
'img' =>'http://www.stammering.org/Images/small_logo.gif'), | |
array( | |
'text'=>'Radio for Milton Keynes', | |
'url' =>'http://crmk.co.uk/', | |
'img' =>'http://crmk.co.uk/images/logos/crmk_logo_std.jpg'), | |
/*array( | |
'text'=>'@nfreear on Twitter', | |
'url' =>'http://twitter.com/nfreear', | |
'img' =>'http://s.twimg.com/images/twitter_logo_header.png'), | |
#http://integratenutrition.co.uk/images/twitter-logo.jpeg'), | |
#http://flickr.com/photos/toonz/3677263997/#CC-by-nc-nd | |
/*array( | |
'text'=>'', | |
'url' =>'', | |
'img' =>''),/**/ | |
); | |
$rand = mt_rand(0, sizeof($links)-1); | |
#echo $rand; | |
$styles = <<<EOS | |
<style> | |
.custom-rot-1, .custom-rot-1 li{margin:0; padding:0 !important; list-style:none !important;} | |
.custom-rot-1 li{position:absolute; top:-9999px; text-align:center;} | |
.custom-rot-1 .show{position:static;} | |
.custom-rot-1 img{max-width:160px; max-height:200px; border:none; margin:0 0 .5em;} | |
.custom-rot-1 span{display:block;} | |
.custom-rot-1 i{position:absolute; top:-99px;} | |
</style> | |
EOS; | |
drupal_set_html_head($styles); | |
?> | |
<ul class="custom-rot-1" xmlns:dc="http://purl.org/dc/elements/1.1/" <?php /*prefix="dc: http://purl.org/dc/terms/"*/ ?>> | |
<?php foreach ($links as $idx => $link): | |
$text = $link['text']; | |
$url = $link['url']; | |
$res = isset($link['isbn']) ? ' rel="dc:identifier" resource="urn:ISBN:'.$link['isbn'].'"' : ''; | |
$image= $idx==$rand && isset($links[$rand]['img']) ? | |
'<img src="'.$links[$rand]['img']."\" alt='' />" : ''; | |
$class= $idx==$rand ? 'class="show"' : ''; | |
?> | |
<li about="<?php echo $url ?>"<?php echo $res ?> <?php echo $class ?>><a rel="bookmark" href="<?php echo $url ?>" | |
><?php echo $image ?><span><?php echo $text ?></span></a></li> | |
<?php endforeach; ?> | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment