first photo instead of album icon

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
Post Reply
macmukka

first photo instead of album icon

Post by macmukka »

SORRY! Meant to post in the Galerix thread - can someone move it?

Great Mod - thanks gratch, just what we needed...

All my work on integrating MooShow and MyGallery is now wasted! ;-) Although it wasnt that important to notice!

Anyway I have slightly changed the mod and thought I'd share it. I didnt want a folder icon for each album so I changed it to the first photo of each of the albums. This is only a frontend change.

My PHP is bad so I have done it the only way I could work out!

change the getAlbumList function in gallery.func.inc.php to:-

Code: Select all

function getAlbumList($albums) {
		$text = "";
		$text .= "<table".getClassHTML("albumlist_table_class").">\n";
		$counter = 0;
		for ($i = 0 ; $i < sizeof($albums) ; $i++) {
			if ($counter == 0) {
				$text .= "<tr>\n";
			}
			$text .= "<td".getClassHTML("albumlist_table_cell_class").">\n";
										
			$text .= "<a href=\"include/inc_module/mod_galerix/open.php?galerix_aid=".
				$albums[$i]["aid"]."\">\n";
			
			$albumID = $albums[$i]["aid"];
			$picture = getFirstPicture($albumID);
			$text .= "<img src=\"".checkEndSlash($GLOBALS["mod_galerix"]["picture_path"]).
			$picture["t_hash"].".".$picture["f_ext"]."\" border=\"0\" width=\"45\" height=\"34\"/>\n<br/>\n";
										
			$text .= htmlentities($albums[$i]["name"]);
			$text .= "</a>\n";
			$text .= "</td>\n";
			$counter++;
			if ($counter >= $GLOBALS["mod_galerix"]["num_albums_in_row"]) {
				$text .= "</tr>\n";
				$counter = 0;
			}
		}
		$text .= "</table>\n";
		return $text;
	}

Next alter the getFirstPicture function in functions.inc.php to:-

Code: Select all

function getFirstPicture($albumID) {
	$query = "SELECT g.pid, g.f_id, g.aid, g.caption, g.position, f.f_hash, ".
		"f.f_ext, g.t_hash FROM `".
		$GLOBALS["mod_galerix"]["picture_table"]."` g JOIN `".DB_PREPEND.
		"phpwcms_file` f ".getJoinString("g", "f", "f_id")." WHERE g.`aid`=".
		$albumID." ORDER BY g.`position` LIMIT 1";
	$result = mysql_query($query) 
		or die(makeErrorMessage(mysql_error(), $query));
		return mysql_fetch_array($result);
}
and this is the view you should get:-

Image

May be some of you will use this. Perhaps we could set up this as an option on the config page, I dont have enough time at the moment!

Hope you dont mind me changing this gratch!

All the best - mac
gratch
Posts: 43
Joined: Tue 21. Nov 2006, 20:36
Location: Passau, Bavaria, Germany
Contact:

Post by gratch »

Hi macmukka,
thanks for sharing your idea :) Of course I don't mind you changing the mod.

Showing the first picture as album symbol is exactly the reason the function getFirstPicture() exists at all! I think I'll integrate this indeed as an option in the backend.

Thanks for your contribution and all the best,
gratch
Saying Bill Gates improved computer security is like saying Osama bin Laden improved flight security.
macmukka

Post by macmukka »

I had a feeling that getFirstPicture() might have been there for a reason!

Just as I was about to write my own getFirstPicture() I found yours!

- Mac
gratch
Posts: 43
Joined: Tue 21. Nov 2006, 20:36
Location: Passau, Bavaria, Germany
Contact:

Post by gratch »

I think at that now I should begin to document the code a bit more :D That's the work that is always left over at the end...

Greetz,
gratch
Saying Bill Gates improved computer security is like saying Osama bin Laden improved flight security.
Post Reply