Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Recently Added Gallery Control
monkeyboy
#1 Posted : Friday, 6 January 2012 2:44:07 AM(UTC)
Rank: Member

Joined: 26/06/2011(UTC)
Posts: 6
Location: uk

Hi Roger,

One of the features my family have been requesting for a while is the ability to see any newly added albums. I created a control using actionmenu.ascx as a template. In order to get a list of recently added albums I created a singleton class which on first access will hydrate all the albums then order by DateAdded desc and takes the top x. The control then simply access this collection and dynamically populates the Items collection of the menu, removing any albums the current user does not have access to.
It works fine but I know that a standalone singleton class is not the best way of doing this, I chose this route so its easy for me to incorporate my changes into any future upgrades.

My question is can you recommend a better way of doing this?

Many Thanks

Dave
Roger Martin
#2 Posted : Friday, 6 January 2012 8:33:26 AM(UTC)
Roger Martin

Rank: Administration

Joined: 3/08/2007(UTC)
Posts: 3,300
Location: Fort Atkinson, WI

I would modify gs\pages\album.ascx to accept a query string parameter like showrecent=true. When present, get the recent albums through a new method in the data access layer (e.g. add Album_GetRecentAlbums() to GalleryServerPro.Provider.Interfaces). The new method would use EF (for SQL CE) or a ADO.NET/stored procedure (for SQL Server) to query the database for the recent items. Then assign the albums to the GalleryObjectsDataSource of the thumbnail view control in album.ascx, like this:

Code:
// AlbumController.GetRecentAlbums() calls the new data access method
IGalleryObjectCollection galleryObjects = AlbumController.GetRecentAlbums();
tv.GalleryObjectsDataSource = galleryObjects;


You can see something similar in gs\pages\search.ascx, as the search page uses this technique to assign gallery objects to the thumbnail view control.

The downside to this approach is that you have to touch several parts of the app, making it harder to upgrade. For that reason, you may just want to stick with your singleton approach.

Roger Martin
Creator and Lead Developer of Gallery Server Pro
Rss Feed  Atom Feed
Users browsing this topic
Guest
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.