I'm building a smallish (about 10 pp. at first) site where almost every page has a unique banner containing an image and some call-to-action text. In the current design the banner sits above the main content area and a left sidebar; the new site will look like this at first but will soon gain a right sidebar. Eventually I'd like to move the banner to one of the sidebars altogether.

I can think of several different ways to do this but I'm looking for recommendations...

If I create each banner as a block it's easy to specify that each block be displayed on the correct "parent" page, but that will lead to a bunch of single-purpose blocks. Is that consistent with the intent of blocks, or are blocks more appropriate for content used across multiple pages?

I can also add text and image fields to the "page" content type I'm using for these pages - which seems appropriate given the one-to-one relationship between banners and pages - but the default rendering causes the field content to be output with the rest of the node. That already makes the sidebar layout a little tricky, and unless there's a way to tell Drupal to render those fields to a different page region, that's going to limit how well the layout will accommodate future changes.

I'm open to suggestions and can provide more info if necessary. Thanks!

Comments

brian_c’s picture

Create CCK fields for your banner settings. Use "Display Fields" settings (tab next to Manage Fields) to hide these fields from node and/or teaser displays.

Then create a new View, with a Node Nid Argument that uses Node ID from URL for "Provide default argument", then add your banner fields. Then create a Block display, and add it to the region you want on the Blocks page.

If your block is showing up when you don't want it (ie on pages with no banner specified) then add a "is not empty" Filter to your view for the relevant field(s).

That should do it, of course you may need to do custom theming to get the block's markup the way you want it, if CSS styling isn't sufficient.

jmcintyre’s picture

Awesome. I almost tried that... but didn't fully understand Views and didn't see how to relate the Node NID to make it work. (Okay, who am I kidding - I barely understand Views.) It almost works like a charm.

The only hitch now is that the banner image displays properly when I preview the Block view in the Views editor, but the actual page just shows a filefield icon and a link to the image file. The image field format is set to "Image" in the view definition.

Thanks for getting me started.

brian_c’s picture

Sounds like you are just using FileField, try using ImageField module (http://drupal.org/project/imagefield) as well.