views:

243

answers:

3

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?

+2  A: 

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.

Rishav Rastogi
+3  A: 

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

Henrik Opel
+1  A: 

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

NonProfit
NonProfit, I updated my question regarding your explanation. Thanks.
D. Pfeffer
Hi D. Pfeffer, I'd suggest you look into http://drupal.org/project/devel specifically the intro video http://drupal.org/files/videocasts/moshe-theme-developer.mov It's sort of like a Firebug for Drupal. As you hover over an element on the page, this module will provide the function which generated it as well as the template (as well as potential templates which will override it) which passed it. It also provides the function arguments which have been passed and their values.
NonProfit