1
votes

Is it possible to , in Drupal 6 using Views, to specify that an image should be shown only if it belongs to the page? I want to make a header image that's different for every page, so each page should show only the image that belongs to it, and none of the image that belong to other page. Or can I do this without Views? I've used ImageField to add the field for the image, but I want it to display in the header, not the content with the node stuff.

1

1 Answers

3
votes

Maybe I misunderstand, but I wouldn't use Views for this. Am I correct that what you want is to display a given image in the header of a given page ? I can see two options :

1) If you page basically display one node, and If you add the image using an imagefield, then you could use CSS to move it out of the content and into the header (using absolute positioning).

Something like :

div.field-field-<your field name> {
  position: absolute;
  top: 50px; /* Adjust to fit your theme */
  left: 0px; /* Adjust to fit your theme */

}

You should make sure you've left enough space for the image at the location you want it. This CSS should go in your theme.


2) You could use a block for each of the images, set the block to display only on the page you want. Go to /admin/build/block/add to create a new block. Add the image under 'block body' - this will depend on your setup, but the general idea is to select an input format that allows images (That is the HTML img tag) and enter the HTML to point to that image, eg. <img src='/path/to/your/image' width='50px' height='50px' />

Then under 'Page specific visbility settings' select 'show on only the listed pages' and enter the path of the page you want this image on.

Save the block, then go to /admin/build/block/list and drag the newly created block in the section you want it to show (eg. header).


Option 2. means you don't have to know CSS/Drupal Themeing, and that the way the page is formated is independant of the node content (which you may or may not want). The downside is that you may end up with a lot of blocks which will make things a bit unwidly. A cleaner way to achieve the same way is to use the context module : http://drupal.org/project/context

There are yet other ways to achieve what you want (Drupal is very flexible), but I hope these are good starting points !