RandomByte :: Forum :: Wiki
 
Writing /home/ecornell/wiki_data/cache/9/97cb5e335ff4c47397609abe88949f4e.i failed
Writing /home/ecornell/wiki_data/cache/9/97cb5e335ff4c47397609abe88949f4e.xhtml failed

I missed the option to filter recent photos by tags. I needed to show just photos with a special tag (for example 'photoblog') to filter out some stuff that i don't like to show in the sidebar (lots of testphotos for example).

So i decided to duplicate the “show_recent” function, call it “show_recent_ex” and enhanced it with the $tags options of the “show_random” function. It would be nice to have that feature build in, in a next version.

But if you like to use that right now, open the FAlbum.class.php and insert this:

	/* nSonic, 01.12.2010: Function to show recent photos filterd by tags - commonly used in the sidebar */
	function show_recent_ex($num = 5, $tags = '', $style = 0, $size = '') {
 
		$this->logger->info("show_recent_ex($num, $tags, $style, $size)");
 
		if ($size == '') {
			$size = $this->options['tsize'];
		}
 
		$output = $this->_get_cached_data("show_recent_ex-$num-$tags-$style-$size");
 
		if (!isset ($output)) {
 
			$output = '';
 
			if ($tags == '') {
				$resp = $this->_call_flickr_php('flickr.photos.search', array ('user_id' => $this->options['nsid'], 'per_page' => $num, 'sort' => 'date-taken-desc'));
			} else {
				$resp = $this->_call_flickr_php('flickr.photos.search', array ('user_id' => $this->options['nsid'], 'tags' => $tags, 'tag_mode' => 'all', 'per_page' => $num)); //'sort' => 'date-taken-desc', , 'page' => '1'));
			}
 
			if (!isset ($resp)) {
				return;
			}
 
			if ($style == 0) {
				$output .= "<ul class='falbum-recent'>\n";
			} else {
				$output .= "<div class='falbum-recent'>\n";
			}
 
			$result = $resp['photos']['photo'];
			$countResult = sizeof($result);
 
			for ($i = 0; $i < $countResult; $i ++) {
				$server = $result[$i]['server'];
				$farm = $result[$i]['farm'];
				$secret = $result[$i]['secret'];
				$photo_id = $result[$i]['id'];
				$photo_title = $result[$i]['title'];
 
				$photo_link = $photo_id;
 
				if ($style == 0) {
					$output .= "<li>\n";
				} else {
					$output .= "<div class='falbum-thumbnail".$this->options['display_dropshadows']."'>";
				}
 
				$thumbnail = $this->_create_flickr_image_url($farm, $server, $photo_id, $secret, $size); 
 
				if ($tags != '') {
					$output .= "<a href='".$this->create_url("tags/$tags/photo/$photo_link/")."'>";
				} else {
					/* $output .= "<a href='".$this->create_url("show/recent/page/$page/photo/$photo_link/")."'>"; */
					$output .= "<a href='".$this->create_url("show/recent/photo/$photo_link/")."'>";
 
				}
 
				$output .= "<img src='$thumbnail' alt=\"".htmlentities($photo_title)."\" title=\"".htmlentities($photo_title)."\" />";
				$output .= "</a>\n";
 
				if ($style == 0) {
					$output .= "</li>\n";
				} else {
					$output .= "</div>\n";
				}
			}
			if ($style == 0) {
				$output .= "</ul>\n";
			} else {
				$output .= "</div>\n";
			}
 
			$this->_set_cached_data("show_recent-$num-$style-$size", $output);
		}
		return $output;
	}
 
falbum/show_recent_filtered_by_tags.txt · Last modified: 2010/01/02 09:04 by 84.132.234.143
 
Recent changes RSS feed Creative Commons License