Hi,

I have a design which requires that the 20 most recent news are presented with the first as a big image, next 3 as small images, and following as text links...

The typical way is to just make an SQL SELECT, and print out the above in a single file with the full layout.

What is the Drupal way?

----

I've tried to make a file called views-view--newslist.tpl.php, but that only has access to a simple layout which would be the same for all nodes.

Basically I just want to get the SQL SELECT without having to write it in-line. Is it possible to access the data result from the above mentioned file?

Thanks!

Comments

TheresaB-1’s picture

I am not real sure what it is your trying to do. Are you saying you want a the most recent news article presented in full as an image (ie picture) and then underneath the next three article in a row as smaller pictures with the remainder as normal text hyper links?

Or do you mean the first article in its entirety WITH a large image followed by the next three articles as teasers with a thumbnail image and then a list of text hyperlinks for the remainder?

mndonx’s picture

The easiest way off the top of my head is to have three views (or, three instances of the same view, actually, since it is Drupal 6): the top story, then next three stories, and the rest. The first two could be blocks at the top of the page view, perhaps.

matiashansen’s picture

I have solved the problem now by doing something like this in views-view--newslist.tpl.php:

- Using Views API to get a the View object (thereby doing the query twice, once by Drupal and once by my code)
- Rendering the first node using in-line formatting
- Rendering the next three nodes by in-line formatting (foreach loop with HTML)
- etc.

My problem is that I want to use Views administration page to administer views, filters etc., but just write one layout file which formats all Views. Also, I do not want to create seperate Page for each View. I just want to use the Path option of the view.

matiashansen’s picture

By using var_dump on get_defined_vars, I found that

$v = $view->display[$display_id]->handler->view->result

gives me an array of the results from the query. But unfortunately, using this method, I do not get the formatted values, e.g. the formatted link, image path etc.