Gossamer Forum
Home : Products : Gossamer Links : Discussions :

additional formatting on grouped links?

Quote Reply
additional formatting on grouped links?
I've been trying to come up with a way to allow post-processing of the links returned by the group by function for some time now. Back in 1.0 even.

What that would be, is either a hash of hashes or hash of arrays. Such that, the category name would be the key to the top array, and the value is a reference to either another hash of the links, or an array of the links.

This would lead to the data structure:

Category_Name1->(Link1, Link2, Link3,....)
Category_Name2->(Link1, Link2, Link3,....)


Ideally, this would be the raw "link" data ie: a hash reference, that could then be sent to the formatting routines. In the worst case situations, we are not returning more than 25 to 50 links at one time, and this would not affect page spanning, or anything else, since it's only the "block" of links that would have been put on the page anyway.

So, once the gb function was finished, the Category_Name1 reference was sent to the routine, and it pointed to a string of references that could then be processed via foreach or similar.

Barring that, the second best option would be for each "Link1", "Link2" etc to be the result of the SiteHTML::display output, and in effect be (what I've been calling) a Link nugget. Then, if Category_Name1 is passed to a routine, all that routine does is string the Link-nuggets together with the proper HTML.

This should _not_ be as hard as I'm making it <G>




PUGDOGŪ
PUGDOGŪ Enterprises, Inc.
FAQ: http://pugdog.com/FAQ


Quote Reply
Re: additional formatting on grouped links? In reply to
Which part are you referring to: New, Cool or Search Results (or all three)? What is the end result you are trying to get?

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: additional formatting on grouped links? In reply to
This is generalizable to all 3 -- new, cool, search etc.

For a 'concrete' example, take a look at the demo "image gallery" site. Look at the searches.

I'd like the images to be able to be grouped across by category, rather than single file down.

I had wanted this in version 1.1x for some other reason, allowing perhaps, a multi-column listing of available titles, or something. But this image layout is a very concrete example.

Right now, the "found" links are all added to a scaler, so you can't do anything else to them. I guess I could put a delimiter in the scaler that would be a unqiue pattern to split it on, but that is not "logical".

On a search, the links are not all returned by category. They seem to be returned by category-by-page. So that on page one, you'll have links in the A category that came up first, but you'll also have links in the A category on subsequent pages.

If the search returned a list of all the link ID's, and inserted them into the category-ordered hash, you could return _all_ links by ordered category in a group. This would not be that much overhead, since even 1000 links would only be 10 bytes or so for the ID and hash entry.

You could then SELECT FROM LINKS WHERE LinkID IN (...) or do a $link_db->get($id) to pull the records up.

Granted, this has some inherent overhead, but it also allows much more control over the output.

Make sense so far? This is sort of a "black box" or "black hole" of seleting links in past versions, and now in this version.

This brings up some very large related issues.

One, is that the "primary" category should really be stored in the Link record, even if it's not used for anything except searches and groupings, doing a join creates a lot of over head. In the CatLinks, there should be an order field, to allow display of links in priority order ... with 1 or 0 being the "primary" and the rest being alternates. This would not affect anything, but it would allow other routines to bypass a lot of overhead.

PUGDOGŪ
PUGDOGŪ Enterprises, Inc.
FAQ: http://pugdog.com/FAQ