PDA

View Full Version : Some thoughts on expanding snippets.php


dscottf
11th of August 2004 (Wed), 13:56
I'd like to propose some features/functions for snippets.php that could turn it into an even more powerful tool. Since this will get long, and many people to not care about the code, I'll do the why part first.

Well first after the who ;)

though my coding skills are meager at best, I am willing to have at it as a learning experience, I have an expert I can draw on (though not always available). There are other experts here as well. The point being I am not asking Pekka to just drop everything and hand this to us.

Pekka, it would be very helpful to have a version of snippets.php with comments (documentation) for each function (what it does and why). I would be willing to treat that as with NDA. I realize this is not an open source project. If you could do that (also to list.php and photo.php (more on that in a bit)) that would be very helpful.

Why:
So snippets can function as a super search engine (both on and offsite)
(I am already using it to sort through and correct category entries)

So snippets can function as a "smart exhibition" (a la iTunes Smart Playlists http://www.apple.com/lae/itunes/smartplaylists.html)

For example: with a simple link (or a form) one could perform a search for, say: all B&W with water from the last 6 months

or one could have a smart exhibition that would contain all waterfalls (and dynamically add any photo that has a category of "waterfall")



How:

I would imagine the logic for smartsearch.php to be somewhat different from the logic of snippets.php

the Get values would be simpler, just get=photos (if you want exhibition names, it's already done snippets). maybe we don't need to specify (?get&[filters])

amount=[integer] would be the same referring to the final result. but add "all" and default to "all"

now we diverge from snippets.php.

what I imagine get=photos does, is build an array which is the results of mysql queries (build a list of photo_ids that match the logic filter).

exhibition= [integer], "all", "latest"

exhibitions=[separated integer list] match any listed exhibition

modified_exhibitions=[string] DESC ASCD exhibitions modified recently (list of all by mod date, sort order, would also serve as "oldest exhibitions")

newerthan_exhibition=[integer] any exhibition modified within x days

exhibition_amount=[integer] limit the amount of exhibitions returned

pass=[string] (limit to public or specified)

min_photo_date [integer] only newer that x days

AND_max_photo_date [integer] only older than x and newer than min_photo_date (allows selecting a date range)

includecategory=[separated integer list], same as snippets.php,

AND_includecategory=[separated integer list], same as snippets.php, except it needs to be AND, not OR boolean (i.e. photos must match the entire list, 16|10= photos with both category 16 and 10 selected)) THIS IS A CRITICAL ONE I don't think we need excludecatagory (or can this be done already with excludecatagory? I can't figure out how)

photographer={integer] should also be a separated integer list and OR function (not AND)

hits_greater_than=[integer] more popular

hits_less_than=[integer] less popular

this list could go on (camera, lens, location, etc) but I think those are the critical ones. Once I see how an array gets built, I can hack in more criteria.

So now we have an array (list?) of photo_ids

sort=[string] ASCD, DESC, RAND (self explanatory?)

viewas=[string] thumb. microthumb, default, list, photo. Default is the default photo size (much bigger than a thumb, better keep amount small, like 1) returned just like thumb and microthumb, list and photo is format as in list.php or photo.php (a full EE page). If "photo" amount must be 1 (for obvious reasons). for the sake of streamlined code, maybe we should have if (viewas == list) include [code to build list page] and for photo. list and photo style should use the same as style for "all exhibitions combined"

(limit by $amount as snippets.php)

target=[string] exhibition, virtual If exhibition, links should go to real exhibition the photo is in. If target is virtual, the array should be stored in the session so that whenever we go to a list or photo view, it view can keep track of where it is at. it should behave as a virtual(transient) exhibition. NOTE: this may be too difficult to implement, but it would allow the same code to be used for "smart exhibitions", see below)

SO this would all work very similar to snippets.php, except that the ?get=latest_photos would become ?get=photos&sort=DESC and ?get=random_photos would become ?get=photos&sort=RAND (

or for my earlier example (all B&W with water from the last 6 months - assume cat 19 is B&W, 10 is water falls, 13 is lakes, 8 is open water)

smartsearh.php?get=exhibition=all&min_photo_date=1 80&AND_includecategory=19|10|13|8&sort=RAND&viewas =thumbs

or only the last 4
smartsearh.php?get=exhibition=all&min_photo_date=1 80&AND_includecategory=19|10|13|8&sort=DESC&amount =4&viewas=thumbs

4 random thumbs from the most recently modified (added to) exhibition (as opposed to 4 random thumbs from any recently added photos)
smartsearh.php?get=exhibition=all&modified_exhibit ions=DESC&exhibition_amount=1&sort=RAND&amount=4&v iewas=thumbs

now:
smartsearh.php?get=exhibition=all&min_photo_date=1 80&AND_includecategory=19|10|13|8&sort=RAND&viewas =list
- which would act like it returns an exhibition (list.php view) matching the search criteria

which brings us to

Smart exhibitions:
this would have to be done by Pekka

if a new type of exhibition could be created that only contained a smartsearch string, but behaved in every other way like a normal exhibition (displayed in all pull downs, responds to a list.php?exhibition=[number] call, though not searchable from list.php) then we would get double the milage out of the same bit of code.

for example: if a "Black and White" smart exhibition called the string: smartsearch.php?get=includecategory=19&sort=DESC&v iewas=list&target=virtual it would look like a gallery of black and white photos, except whenever I added a new B&W photo anywhere (category 19) it would automagically appear when this (smart) exhibition was called.

The same code could be used for a dedicated "search" page (checkboxes of categories, enter dates, etc). The code from a search page could be the user interface for creating a smart exhibition.

--

In conclusion, most of this seems like it could be built using existing code functions (though only Pekka knows which ones right now) and some of us could (with help) figure it out and contribute it back to EE.

Thoughts?