Hello people

A beginner question which I hope won't take much time or effort to answer...

I'd just like to know whether Views can or can't do the type of query I have in mind.

(If so, I'm not asking you to tell me how - I just would rather not set off down a tunnel with no cheese at the end :-) )

==

I want my front page to have

- Most-recently-dated node of one particular node-type, text in full
- Header "Other stuff"
- A few nodes of other types, identified simply by the "Publish to front page" flag.

So I am imagining a query along the lines of

SELECT [nodes] FROM [wherever they're kept]
WHERE node-type=my_new_type
LIMIT 1

And then another query like

SELECT [nodes] FROM [wherever they're kept]
WHERE published=yes

then add the two results together (which may be the tricky bit (?))

then ORDER BY node-type, date DESC (presuming that the node-types of the "other stuff" nodes were either all alphabetically before, or all after, the name of my new type, and adding DESC if necessary).

Can Views do that?

Or, if that wouldn't work, would an alternative be to do two separate Views and put them into Panels? (slightly less desirable only inasmuch as I'd then be waiting for a stable Panels for D6)

Or am I on the wrong track entirely?

==

Thanks in advance for any feedback/reassurance/"no it won't do that so don't bother trying".

Jennifer

Comments

deshilachado’s picture

I'm not a Views expert, but I'll try to answer your question. Doing the two queries will be easy (this is exactly what Views is supposed to do) and yes, the tricky part is adding those two together. Several solutions come to my mind on how to do it:

  • You can create a view and then attach a second view to it (Create a new display of 'attachment' type).
  • You can create a page and then insert two views into the page as described here: http://drupal.org/node/336097
    This gives you a lot of flexibilty as your page is a normal node.
  • You can use Views Fusion which is a project written for fusing multiple views into one. Read this article http://drupal.org/node/130944 or go to the project page: http://drupal.org/project/views_fusion
  • You suggested Panels yourself and probably there are many more ways to do this...

If one of the ways works for you, please write back how you did it finally.

Jennifer_M’s picture

Thanks, that's a really helpful summary!

You can create a page and then insert two views into the page as described here: http://drupal.org/node/336097
This gives you a lot of flexibilty as your page is a normal node.

That method looks at first glance like the most promising one for me, as I may well want different formatting for the two different chunks anyway. I'll give it a try.

If one of the ways works for you, please write back how you did it finally.

OK, will do :-)

shunting’s picture

You could also use the insert_view module. It's an input format with a lot of options. Mine looks like:

[view:{view_name}=={view_parameters}]

So, you don't have to enable PHP coding at all, you can embed as many views in a node as you like, there's no additional setup other than creating the view, and as a bonus, the technique works in blocks.

Jennifer_M’s picture

Thanks, that looks possibly useful too...

deshilachado’s picture

Status: Active » Fixed
Jennifer_M’s picture

Keeping my promise to report back...

I've got a fairly simple solution now that works almost perfectly, with one relatively work-aroundable disadvantage.

==

What I did was

1. Installed (a) Views and (b) insert_view.

2. Created a View which would always show the most recent "overview" node, calling it most_recent_overview.

3. Created a block whose only content was the instruction "[view:most_recent_overview]". (Note for anyone following this method: the block's "Input format" has to be "insert_views_special_format".)

4. Created a new Region to go at the top of the content area. Handily, this is one of the things they tell you how to do in the "Using Drupal" book.

5. Made the block appear in the new Region.

==

This means that my front page always has the most recent Overview post at the top. Which is exactly what I wanted. And because I've put it in a separate block, I can easily format the overview section differently from the rest if I want to.

Any other posts I flag to publish to the front page will simply appear below the Overview block - again, exactly what I wanted.

I've changed my mind now about having a separate heading for the rest of the page. I decided it'd look OK with each subsequent node just having its own heading.

But there's one catch for which I haven't yet found a satisfactory solution: If I don't flag any other nodes to be published to the front page, I get the automated "Welcome to your new Drupal website!" quasi-post instead!

I'd like to be able to just switch that off - seeing as the front page will now always include meaningful content from the overview block - but from what I gather, that's not actually possible.

I realise that an alternative would be to not have "node" as my front page - but then I've lost the elegance and flexibility of the default "publish to front page" checkbox, when I do want to add something.

So it looks as though I'm going to have some kind of at least slight compromise - perhaps stick with "node" but have some kind of permanent sort-of-dummy post of my own, which would appear at the bottom of the front page. Other suggestions welcome.

However, aside from that, this is seeming like a good solution for me for now. Thanks to everyone who gave advice!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.