views:

129

answers:

2

I've got a design in drupal that calls for a different background image on different pages. I'd like to make it easy for the site editors to assign the image. My first thought was adding a cck field to the Page type where they could assign the image. That will work nicely for node pages, but won't work for views pages. I guess instead of creating the views pages directly, I could wrap them in nodes.

My other idea is to create a BGImage cck type, and then some kind of matrix page where they can assign a given BGImage node to a content node or view, but that sounds complex.

Any better ideas out there? (In a way, this is akin to controlling block visibility, I suppose.)

A: 

I would indeed suggest to wrap them into nodes, the Views Attach Module might help here.

alexanderpas
+1  A: 

After creating a content type to use as a repository for background images, I think that it would be a fairly quick module to give you a block with dropdown box to choose from uploaded images.

Look up hook_block for the only hook you'll need.

if $op == view pseudocode follows (but it should be clear enough to go on)

$res = db_query('select field_my_image_fid FROM {mycontenttype}');
while ($img = db_fetch_obj($res) {
  $my_content .= $img->whatever

return array(
 'subject' => '<none>',
 'content' => $my_content
)
Jason Smith