Add two fields to the album edit page

A forum for discussing possible new features or changes to netPhotoGraphics. But NOTE, only a formal request via the GitHub repository ticket system is tracked or responded to.
Post Reply
Eddie
Posts: 30
Joined: Sat Apr 25, 2020 8:41 pm

Add two fields to the album edit page

Post by Eddie »

Hi Stephen, Feature request: Is it possible to add two fields to the edit album page? Ideally it would be two selection dropdown fields. One where you can select a news category to be displayed for that album and one where you can select latest or random images for that specific album. The latest/random images would be via a selection where you can select the specific album or sub-album from that album hierarchical group.
Then have two standard codes (printAlbumlatestimages and printAlbumNewscategory) to pull those two up on the front end, or maybe via codeblock. This way you can have insight in latest images and news per album. If this would be possible, it would be great!
Last edited by Eddie on Wed Jul 12, 2023 1:47 pm, edited 2 times in total.
Eddie
Posts: 30
Joined: Sat Apr 25, 2020 8:41 pm

Re: Add two fields to the album edit page

Post by Eddie »

The PrintAlbumlatestimages would be based on the already existing printImageStatistic, but it would then only show it for images for the selected album or selected sub level album. The printAlbumNewscategory would show news items based on the category that you select.
stephenbillard
Site Admin
Posts: 85
Joined: Tue Aug 14, 2018 6:33 pm
Location: Huntington Beach, CA, USA

Re: Add two fields to the album edit page

Post by stephenbillard »

The news category sounds like a reasonable addition. I think that all that is needed there is to have an album property that contains the news category (if set.) The theme can then decide exactly what to do with that information. (Display the most recent article? Link to the category? etc.) Maybe this should be more general--perhaps an nPG object associated with the album (and maybe other objects could have this property as well.)

I am not sure what difference there really is between the album image request and what currently is possible with the album thumbnail. I presume that whatever displaying you wanted would be on the album page. Again, for flexibility I think the theme should determine what/how the image is handled. So you can just use $albumObject->getThumb() to get the image.
-Stephen
stephenbillard
Site Admin
Posts: 85
Joined: Tue Aug 14, 2018 6:33 pm
Location: Huntington Beach, CA, USA

Re: Add two fields to the album edit page

Post by stephenbillard »

Upon further thought, I think the best solution for then news category/album property is to name your categories the same (or based on) the album name. Then no extra properties for the album are needed then.

For the latest/random images there is no need for an album property. There is already a getImages() method for albums that can return the image list in a random order ($sorttype='RAND()') or latest ($sorttype='date'). All that is missing from your request is a means to get all the album and subalbum images. That function is shown below and will be added to the template-functions.php script in the next release.

Code: Select all

function getAllImages($album = NULL, $sorttype = NULL, $sortdirection = 'DESC') {
	global $_current_album;
	$sortby = trim(lookupSortKey($sorttype, 'filename', 'images'), '`');
	if (is_null($album))
		$album = $_current_album;
	if (!is_object($album)) {
		return;
	}
	$albumsList = getAllAlbums($album);
	array_unshift($albumsList, $album->name);
	$list = array();
	foreach ($albumsList as $subalbums) {
		$album = newAlbum($subalbums);
		$images = $album->getImages(0);
		foreach ($images as $image) {
			$anImage = newImage($album, $image);
			$list[] = array('album' => $album->name, 'image' => $image, $sortby => $anImage->get($sortby));
		}
	}
	if ($sortby && !empty($list)) {
		$list = sortMultiArray($list, $sortby, strtolower($sortdirection) != 'asc');
	}
	return $list;
}
-Stephen
stephenbillard
Site Admin
Posts: 85
Joined: Tue Aug 14, 2018 6:33 pm
Location: Huntington Beach, CA, USA

Re: Add two fields to the album edit page

Post by stephenbillard »

The development release now has this function added (along with some enhancements) You can find the development release at https://github.com/sbillard/netPhotoGra ... Dev_2.0%2B
-Stephen
Eddie
Posts: 30
Joined: Sat Apr 25, 2020 8:41 pm

Re: Add two fields to the album edit page

Post by Eddie »

Thank you so much for your kind support. I got the latest images to work. It is really insightful to see this in my sidebar as it shows latest additions for each album. Works like a charm! Thank you for adding the function! Concerning the news items per album. Is there a way you can pull up news items per category? Maybe I can create a function for each of my albums that I then reference in a codeblock?
Post Reply