Making an archive page that shows images

Hi everyone

I'm setting up ZenPhoto and it's all going very well so far, I'm working from the default theme customizing left and right. I got the main page, picture page and to an extent the album pages to look the way I want but I've hit a wall with the Archive page.

What I would like, instead of the plain list of links that the default theme has, something like:

2010
January
[img] [img] [img]

February
[img] [img] [img]

etc...

Each month would list all the pictures for that month, chronologically, regardless if it's 1 image or 100. Albums should be disregarded completely here.

Surely this can't be THAT hard, can it? I've tried moving some of the functionality over from the Search page to the Archive page, but all I've really managed is to blow it up about a dozen different ways. I'm not making enough sense out of the inner workings of ZP, and the fact that PHP isn't my native language (I code in .NET, have only a basic grasp on PHP) isn't helping either.

Could someone at least point me in the right direction with this?

Comments

  • You should start by reading the themeing guide if you have not already done so. Also the bit on the Zenphoto object model. You will have to build this view out of those tools.

    Essentially what you need to do is add in-line the code that the search page uses when it is passed a "date". But of course, since you have not actually caused a search to be set up, you will have to do that as part of your code. That is, you will have to instantiate a search object for each "date" and use the object methods to get the images it finds.
  • Hmm, could the CombiNews feature be used to do this? The getCombiNews function looks like it takes the style as a parameter, so it can be used to display a different result set than the database is configured to display on the news page. Something like:

    getCombiNews(50, 'latestimages-thumbnail', 'published');

    Then you can loop through the results, and print only image results, ignoring news pages.
  • acrylian Administrator, Developer
    That would be a way. Or try the CombiNews option "Lastest images by album" which will group all images that have been uploaded on a specific day to the same album as one entry.
  • lazar Member
    Thanks for the replies everyone.

    What I've done is take the code of the printAllDates function since that does the breakdown by month nicely (skips months with no pics) and inside of that I am trying to run an Image Loop like the album and search pages have. Where I'm hitting a wall is that I don't know how to instantiate a virtual (search) album to loop through. I already have the looped date in the $key variable, I can use that to make the search param, but how do you make an album instance explicitly in every loop iteration? The other pages all seem to do this implicitly, from the querystring, and if it's explained in the docs I haven't found it.

    Sorry for being thick and thanks.
  • acrylian Administrator, Developer
    You have to work with the object model as sbillard already mentioned (see the tutorial for that first and also the documentation). Those loops depend on album/image object that are carried in global variables. But those are only setup in the right context automatically.
  • lazar Member
    Ok, after a delay I'm back to trying to get this to work.

    Yes, I've read the ZP object guide and the themeing tutorial and been all over the element index and the forums but still cannot figure out how to do this one thing.

    I can set $_zp_current_album to any physical album and then the image loop works (with the images in that album), but can't figure out how to set it to use results of a search, in my case a date. Which is essentially what I need to do, correct?
  • You will have to setup the a complete search context. This means setting the `$_zp_current_search` up, setting `$_zp_current_context` correctly, and setting the search engine paremeters for the search you want.
  • lazar Member
    Is there an example anywhere on how you do that? There must be a function somewhere that does this that I can use as a starting point.

    I looked at search.php but couldn't find anything that sets up the search context, at least not explicitly.
  • acrylian Administrator, Developer
    Search for "context" on the documentation and look at existing files like template-functions.php for example. Context stuff is used there a lot.
  • I think there is no example for just what you are trying to do. Normally search context is setup from the POST parameters of from saved cookies. Perhaps you can look at how those are done and go from there. In particular there is a function `loadSearch()` in functions-controller that is where the post handling gets done. You can also look at how dynamic albums are setup as a further example.
Sign In or Register to comment.