Am I understanding Drupal regions and views correctly?

1k views Asked by At

We're building a very content rich site in Drupal. It's my first time working with it. There are a variety of sections to this site, each with a different layout. I plan on determining the page.tpl.php via the phptemplate_preprocess_page() method.

My question is how best to specify where in a given page to put different chunks of secondary content. We've got a lot of sidebar type components, each with several small lists or groups of images. I think the best approach here is to define multiple regions as needed and drop in custom views (using the Views module) into these regions. Does that seem reasonable?

Update:

Regarding treating Views as queries - what confuses me is that the Views also have options to modify their appearance. I'd prefer if I could just get an array of nodes back from a View so I could operate on the data in PHP, rather than formatted markup. Is that possible?

3

There are 3 answers

0
Henrik Opel On BEST ANSWER

To expand a bit on Rishavs (correct) answer, blocks are the 'standard' element to fill regions. The regions in your page.tpl.php define the broad, general layout (e.g. a header, some columns/sidebars and a footer - anything you need). Within a region, you might place only one thing (e.g. a view), but usually more in the form of several blocks. The order in which they appear in the regions is determined by the blocks weight.

You can create blocks directly in the views module by adding displays of type block to a 'base' view definition. Also, every menu you define will be available as a block. It is also pretty straight forward to create your own blocks within custom modules, giving you full control over its contents (see hook_block() for this). That way, for example, you can put forms into blocks (the login block of a standard Drupal installation is an example for this).

0
Rishav Rastogi On

Yes, you can use custom regions, and drop in custom views into them.

You can even use create custom blocks and use views in them.

It depends on the structure of the layout you have.

2
NonProfit On

A View (a list of content) is a database query. A region is an area of the page (left sidebar, footer, etc.). Regions are assigned in the page template (the tpl.php's) and will vary depending on the theme you are using. Typically, secondary content (including, but not limited to, Views) is placed via blocks. Blocks are displayed when they are assigned to a region ("New Users" in the "Right Sidebar"). Also, Views can also be embedded in a page template (either inside out outside of a region).