A Tumblr experiment by Alison K.
:: 2012 ::
The Museum of Boring Objects was inspired by a talk given by David Small of Small Design Firm at Massachusetts College of Art and Design in 2012. He mentioned a facetious "boring objects museum" in passing, and I liked the idea as a platform for a code experiment. Some of these objects are more boring than others, but none of them come from a museum. I have touched and used all of them personally.
I created this project as an experiment to see whether it is possible to sort all posts in a Tumblr by tag, rather than the default of sorting them by date. Tumblr already allows authors and visitors to select and sort for one tag at a time (generating a page displaying only every post tagged "yellow") but there is not yet any way to display all posts simultaneously sorted by their tags rather than chronologically. This is what I set out to create, using the Museum of Boring Objects' holdings as a dataset.
The Museum of Boring Objects is a Tumblr (http://boringmuseum.tumblr.com), whose posts have been re-sorted by tag, so they are now ordered by color, not date posted. In order to accomplish this via PHP, the main content of the site is hosted on my own server, based on an XML feed from http://boringmuseum.tumblr.com. The "home" page of the Museum is a Tumblr URL, which serves as a portal to the Museum's entire content. Tumblr themes can't contain PHP, so if you want to do something similar hosted 100% by a Tumblr account you'd have to try JavaScript or something similar to recreate the code at right.
Questions? Comments? Contact me.
<?php //a pre-fab library to help with importing XML to pho from Tumblr //Read about it and download it here: //http://code.google.com/p/phptumblr/wiki/Documentation require dirname(__FILE__).'/phpTumblr/clearbricks/_common.php'; require dirname(__FILE__).'/phpTumblr/class.read.tumblr.php'; //import the Tumblr feed
//put the name of your Tumblr here where I've used 'boringmusuem' $tumblrObj = new readTumblr('boringmuseum'); //how many posts? Also, what kind? $tumblrObj->getPosts(0,100,photo); //Create an array from the XML feed $tumblrArr = $tumblrObj->dumpArray(); //Create a (non dynamic) arrary of the tags you've used $allTags = array( '0' => 'red', '1' => 'orange', '2' => 'yellow', '3' => 'green', '4' => 'blue', '5' => 'purple', '6' => 'pink', '7' => 'black', '8' => 'white', '9' => 'metallic' ); //count how many posts are in the imported XML $numPosts = count($tumblrArr['posts']); //If you want to sort the tags alphabetically by name, //rather than by key (as they are sorted automatically) use: //array_multisort(array_values($allTags), array_keys($allTags), $allTags); //Get the relevant content from the XML array //Display the content in order by tag $i = 0; //preset variable for do/while loop (default is 1, unless specified). do{ foreach($tumblrArr['posts'] as $key => $val){ $imgSrc = $val['content']['url-250']; $myTags = $val['tags']['0']; $myUrl = $val['url']; displayMe($imgSrc, $myTags, $myUrl, $allTags[$i]); } $i++; } while ($i <= $numPosts); //display the relevant Tumblr content, within a DIV function displayMe($imgSrc, $myTags, $myUrl, $mySort){ if($myTags == $mySort){ echo "<div class='article'>"; echo "<img src='"; echo $imgSrc; echo "'>"; echo "</div>"; /* If you want, uncomment this snippet and the IMG will link to it's corresponding Tumblr page echo "<div class='article'>"; echo "<a href='"; echo $myUrl; echo "'><img src='"; echo $imgSrc; echo "'></a> <br />"; echo "</div>"; */ } } ?>