ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Grabbing newest photos from Gallery & other Gallery Module queries (football site)

July 22, 2007 11:18am

Subscribe [1]
  • #1 / Jul 22, 2007 11:18am

    Gizmo

    5 posts

    Hi all,

    I’ve been searching the forums for a couple of hours now, and have seen many posts sort of skirt around the questions I am trying to answer, or suggest things that are not quite what I am looking for. I was wondering if anyone can help with the following? I am quite familiar with EE, but not specifically the Gallery Module.

    With the Gallery Module, I haven’t quite decided if it is better to have multiple galleries, or multiple categories/sub-categories within a gallery, or both (any advice on these?), but in any situation, would these be possible:

    1) Have 1 gallery/category that is only viewable to members that have logged in. I.e. members see gallery/category 1, 2 & 3, and non-members only see 1 & 2 (and all the photos contained therein of course)

    2) Am I able to grab the latest (or a random) photo from the newest gallery/category and post it on the index page of my main site?

    What I am looking at doing is having 3 galleries (I guess):

    - On-pitch action
    - Off-pitch action
    - Restricted

    And so on the index pages of my site along with the rest of my content I would like to have a random/newest photo taken from the newest category within ‘On-pitch action’. So effectively the newest photo from that gallery

    Separate from that, is it possible to simply select a random image from either of the first two galleries to put on my index page?

    And also for the ‘Restricted’ gallery to be viewable by those who are logged in.

    Any advice is greatly appreciated - sorry for all the questions!!

    cheers!

    Moved to HowTo by Moderator

  • #2 / Jul 23, 2007 11:32am

    Robin Sowell

    13255 posts

    The random image bit will be doable regardless of how you set things up.  If they’re all in the same gallery, you could just use the gallery entry tag, a category parameter to prevent entries from the ‘restricted’ category from being included, and the orderby=“random” parameter to handle the random factor (see gallery tag parameters.

    That wouldn’t work if they were in different galleries, but then you could just use the query module to pull directly from the database.  More complicated, but considerably finer grained control.

    So- doable, but ‘how’ depends on how things are set up.

    Which leads us to the second question- and again the short answer will be ‘doable’- but I’m less certain on how I would go at it.  Probably the easiest thing is to have 2-3 galleries.  At least, have the restricted gallery be its own gallery and put it on its own template group- then use template access restrictions to lock out non-members or certain member groups from viewing.  That’s one way.  The negative- if you have multiple template groups for showing your gallery(s) you add a bit more work keeping them up.  Have to change things in 2 places rather than 1.  Of course, most folks will break out headers/footers/nav into embeds or globals, so that’s general not a big deal anyway.

    The other option is flipping out parameters based on membership status.  More complicated to set up, but you can keep it all in one gallery.  However- if the restricted bits really are ‘on-pitch’ and ‘off-pitch’ but vary only according to being restricted?  Then I start leaning toward doing it this way.  Will make for a better navigation/presentation for your logged in members.  I think.  Well- just depends on what you think, really.

    So- I think it just depends on what will be easier/better for you in the long run.  It’s doable for sure, but the approach will vary depending on a number of factors.

    If you’re just starting to explore EE, I’d really suggest taking it for a test run.  There are a number of ways you can test it out- I’d suggest the hosted trial for what you’re interested in doing.  You’ll get the best feel for EE when you actually start building the site.

    Overall- make sense?

  • #3 / Aug 04, 2007 6:57am

    Gizmo

    5 posts

    Thanks to the Mod who moved the topic - I realised almost as soon as I wrote it that it was in the wrong section - my apologies.

    Thanks for getting back to me Robin.
    I understand what you mean about the category parameter, and exclude the restricted one (if it is in that gallery to begin with). What if I wanted to grab a random image from the most recent category within a gallery though?

    Using the category parameter and orderby=random would select a random image from all the categories not excluded? I would look to have it just choose randomly from within the most recent category.
    If this category always had the id ‘1’ that would be doable, but i guess the IDs go up (newest with highest number?)

    Any thoughts on how to find the most recent category within a gallery and then choose a random image from it?

    thanks in advance!

  • #4 / Aug 23, 2007 11:25am

    Gizmo

    5 posts

    Alas… I think this is impossible?

    I can grab a random image from a gallery or a specific category in a gallery
    I can grab the newest image from a gallery or a specific category in a gallery

    But I cannot grab a random image from the newest category in a gallery.

    Would anybody be able to confirm that this is impossible? I’ve spent a few days on it, but if it isn’t doable I’ll move on. 😛
    Or can a query be used?

  • #5 / Aug 23, 2007 11:40am

    Robin Sowell

    13255 posts

    Well, the categories don’t have a ‘date created’ column, but the id is auto-incremented.  So to get the most recent cat, could do a query, limit 1, order by cat id.  That should work to tell you the most recently created cat.  Make sense?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases