Hey, I've been checking out ZP and I really like how it gets the job done so simply. I'm making a graphics portfolio site, with a bunch of info pages (home, about, contact etc.), a portfolio index, and separate albums for different portfolio projects. I'm using wordpress, and I've been trying to figure out how to use ZP in a WP template to display thumbnails etc from a specific album.
I've noticed a problem with how ZP resolves a query string to a particular album/image/etc. The code that does that is in template-functions.php, is at the global scope, and gets the query params directly from the _GET. So you can't use this if you're not actually querying for the album/image, and you just want to include it in another page. I noticed that the ZenPress plugin, to get around this, actually does it's own MySQL queries to get the album and images. Requiring this is duplication and forces the developer to learn your DB schema.
So I propose a refactor of template-functions.php to be more like the WordPress loop, which has functions like:
query_posts('category_name=special_cat&showposts=10');
which allows you to query for objects without the actual HTTP GET, have multiple albums in one page, mix WP and ZP without making your own MySQL queries and knowing the DB schema etc.
More info on the WP loop is here
http://codex.wordpress.org/The_Loop#Multiple_LoopsWhat do you think? I could do this if you don't have time.
Mike Lin
Comments
You're completely correct about refactoring that into a functional way of querying the database for the correct contextual variables.
However I don't like to copy Wordpress. I kind of like to rethink everything they do, because it can usually be done better. No offense, it's obviously a great marketing and community success, but it's not usually perfect code...
Example: WordPress' actual loop looks like:
`<?php while (have_posts()) : the_post(); ?>`
There's no reason for the two function calls. A little rethinking can reduce it to one,
`<?php while (next_image()): ?>`
as in Zenphoto.
So while I don't have this faithful respect for Wordpress, I do certainly agree that the Controller needs to be refactored into a publicly usable interface. Thanks for the excellent suggestion!
I'll use DB queries for now, but I look forward to the next version. Thanks for such an intuitive photo gallery.