Welcome Guest, Not a member yet? Register   Sign In
Advice on URL/controller structure and "permalinks"
#1

[eluser]derekt[/eluser]
Hi all,

I'm looking for your suggestions on MVC controller structure for a photo gallery site that will have collections of photos and multiple groups of collections, while maintaining "permalinks" for individual photos that can be in many collections.

I gather that the standard MVC URL structure would be:
mysite.com/collection_group_name/collection_name/photo_name

Thing is that a photo can be in many collections, so what would be the ideal location for a permalink? My thought was to have a separate controller for the photo detail page, at say
mysite.com/photo/photo_name
but the issue is then how should I tell my photo controller which collection a photo is in when users click through the next/prev links on a photo detail page? I've seen this done by setting a global containing the collection id when a user is in a collection, but that seems icky and un-right.

Advice from those experienced in this kind of thing is highly appreciated!
#2

[eluser]theprodigy[/eluser]
If you are setting a photo details page, un-related to the collection that it is in (such as mysite.com/photo/photo_name), then maybe you should show a list of all the galleries that photo is in. Or, you might be able to get away with just storing the category id in session, and pull the category info from that.
#3

[eluser]jedd[/eluser]
[quote author="derekt" date="1265087142"]
I'm looking for your suggestions on MVC controller structure for a photo gallery site that will have collections of photos and multiple groups of collections, while maintaining "permalinks" for individual photos that can be in many collections.
[/quote]

You don't mention what approach you're using (schema-wise) to manage your groupings.

Quote:Thing is that a photo can be in many collections, so what would be the ideal location for a permalink? My thought was to have a separate controller for the photo detail page, at say mysite.com/photo/photo_name but the issue is then how should I tell my photo controller which collection a photo is in when users click through the next/prev links on a photo detail page?

Again, without a schema, it's hard to know what direction you're trying to take things.

Obvious choices here include having a default group for each photo (that's in multiple groups) or some algorithm for determining the better group (f.e. the one that contains more photos).

Alternatively consider that you may want URLs that contain lots of meaning - for when people send them around - that is, containing the photo ID as well as the group(s) that are being shown currently. This just means you need a more imaginative way of defining your URLs. For example site.com.au/photo/P_id/G_group1/G_group2 .. or variations.

When I wrote my gallery I was:
a) limited / defined in my direction by the backend I was using (KPhotoAlbum)
b) keen on having URLs that contained as much information as possible - I have filters, rather than groups, and I can have an arbitrary number of filters - which will define the thumbs shown. I can also be showing an image that isn't in the thumb set (it's faster to navigate around the latter, without reloading a new former all the time).

You're welcome to check my code at [url="http://dingogully.com.au/trac/phoko"]my trac site[/url] if you're interested. It's far from perfect PHP / CI / MVC, as I eschew OO and am not, by any stretch, a strong programmer. But having said that you may get some ideas you can develop upon.
#4

[eluser]derekt[/eluser]
theprodigy - great point - I should put links to the galleries that each photo is in, which would help users find collections of photos they're after. As for putting the category id in a session, I could, but intuition tells me that I should try and minimize use of db and server resources for the sake of best performance, no?

jedd - I've set up dbs for photos, collections, and collection groups, with map tables defining which photo goes in which collection id, then which collection goes in which collection group. Single photos can be in many collections, and single collections can be in many collection groups. Also, thanks for the link, though I wasn't able to access the URL (server unexpectedly dropped the connection).

The Codeigniter/MVC way seems to suggest I pass collection group, category and photo in the URL like so:
site.com/travel-photos/fiji/clownfish
site.com/stock-photos/fish/clownfish

The results is many many URLs, which is fine, except that:
a) I'd like to provide others (especially search engines) with a single URL
b) I use CI's caching, so the result is a large number of cached files

I looked at how WordPress does this for news posts, and they use a single URL for an item's "permalink" (posts/news-headlines/post-name), then set a global which contains "category" and then make the category available via an "is_category" function so one can build the breadcrumb and next/prev links.

I can do whatever, but would love to have the advice of those who know much better than this photographer =)
#5

[eluser]jedd[/eluser]
I think your problem is not specific to photo galleries - the same thing will happen to any content that has tags (for example) as there's several ways to arrive at the same place.

The only way to prevent that, as I see it, is to have unique URLs for every thing but for the context (what stream you're in, what tag set you're in, what filters you've got, etc) you keep that in session data.

As I mentioned before, I think that's really ugly. If Google reckons that my pictures of lizards, plants and bridges are a sly attempt to sell something, and so rate me lower, because there's several different URL's that contain the same image & text .. well, I guess somehow I'll find a way to struggle on with my life. If your site's a commercial proposition then I guess you can't be so insouciant about the matter.

Oh - my site should be back now, btw. Went a bit haywire yesterday - shouldn't have, though, as I was just munging around with some unrelated VM's on the server. Oh well. Computers are like that.
#6

[eluser]derekt[/eluser]
I've decided on a solution here, so let me share.

First off, thanks again jedd for your second reply, and you are completely correct that this isn't specific to photos - it's a more abstract issue about any "thing" that is unique but can be found in multiple places...could be blog posts, links, photos, whatever.

My main question has been what to call the "permalink". Based on your replies and the research I've done, the answer seems to be that each "thing" becomes a unique thing in each instance, wherever it may be listed. In my case, each photo a unique "thing" every time it appears in a category, thus it gets a separate URL.

Regarding the search engines, the exposure they provide is important to my goals for the site, so I've spent a lot of time researching how this works. It's my understanding that they basically apply "Ranking goodness" to a photo (which can be at multiple URLs). Obviously in a photo gallery UI, you're going to find multiple instances of a photo, and they are cool with that, but one thing you want to do is make sure they don't spread the "ranking goodness" across multiple URLs where the photo may exist: you want all the goodness applied to a single instance at a single URL. Long story short, the answer is that I should define for each image a "primary" permalink, then let programatically let search engines know to which URL the ranking goodness should flow.




Theme © iAndrew 2016 - Forum software by © MyBB