Cascaded queries, dependent views, passing context around from view to view, ...

Events happening in the community are now at Drupal community events on www.drupal.org.
Annakan's picture

Hello all, and thanks for the great view module, especially to merlinofchaos.

I did some research and did not find a thing even remotely connected to this so I'll try to explain the problem and the few solutions I have in mind, hoping the experts here will be able to guide me toward means to realize them or advice me. Or plug my nose on a "fucking manual 'RTFM' way".
I thought this http://drupaleasy.com/blogs/ryanprice/2008/06/using-views-2-drupal-6-cre... and this thread http://groups.drupal.org/node/37414 could be related but I think my case is more general. Slap me if I am wrong. ;)

The problem :

Let's imagine we have a newspaper-like publication.
You have a top story, on top of the page, and then fixed topics (about cats, dogs, new news, old stories, whatever).
Every story is "tagged" in taxonomy, and can belong to several ones...
Of course, on the front page you want :
- the most recent story in the top story panel
- the most recent story in every topic in the fixed panel dedicated to that topic, but one that is NOT the top story and NOT already a frontage story for another topic (not already the most recent story for a "previously rendered" topic that is not the "top story")

Said more simply : a "story" should appear once and only once on the frontpage being as the top story or the featured story in a topic.

Several strategies come to mind to achieve this but all revolve around givin a query, and thus a view (programatic or else), some context about the current page rendering.

First : Can I be assured of a fixed order or rendering given the fixed rendering order of the html page : front left to right and top to bottom like is ordered the html/css flow ?

Strategy one : embedded queries or "not in" or sub select ..

is there a way to build a query that said

select (all stories) from (that topic) that are NOT IN (that other query result set) .. order by date, sticky first etc

I could then create a view for each topic in the order of rendering, ugly but it should work

Strategy two : passing some context around

A probably more efficient strategy would be to store each "story/node" already picked up by a previous rendering of views and exclude it from the result set.

I imagine a special view that after query, exclude from its result set the node inside a "global-given-passed-around" transient array-variable (only valid during page rendering) and the add the displayed node to that array.
That way I could build a view with display selecting each topic and each time a particular display is called it would automa(t/g)ically exclude previously displayed nodes in a previous render of another display of the view.

Is that possible ?
More exactly, what variable could I use ? I envisioned using the request for that but is it allowed to add data to the request ? is there already a mechanism in drupal for transient-request duration only variables ?

Do you think this mechanism could be useful enough that we could have in views such a capability ? Choosing in what variable the displayed node/thing/result set would be added and having the option to either start from that list of "things" or exclude that list of "things" (polymorphic meaning here) from another result set ...

Am I going bonkers there ? with a more obvious solution right in front of me ? Or am I pushing views too far (that's just not possible right ;) ).

I am unconscious enough to envision either a "simple" hook patch in an add hock module perverting a given named view or a new kind of display, even If I would not know how to build that from scratch, I am willing to learn. One could lead to the other and help test the water.

Thanks a lot for your time reading this and eventual advices ..

Comments

of course

Annakan's picture

Of course right after writing this, I started to wonder if Panels where not the place to store that context data, somehow updating a panel variable from each view and taking into account node previously elected by another view to pick up the proper node for the "next topic" view from that data stored in the panel-display object ...
Is it the proper way to do it ?
And is so could anyone name me some pointers inside the panel and view api to pass around datas ? should had create a new kind of panel display programmaticaly for that ?

Still digging but all pointers and critics welcomed (ok mostly all :) )

Cheers

Views Developers

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: