Search code examples
drupaldrupal-viewsdrupal-blocksdrupal-regions

Am I understanding Drupal regions and views correctly?


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?


Solution

  • 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).