Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions

Help with header


Go to End
Reply

24 Posts   4060 Views

Avatar
Webdoc

6 October 2009 at 5:49am Community Member, 332 Posts

Can someone please explain how i can make the header image that changes when u change page

homepage - header 1
products - header 2
1st product group - header 3
2nd product group - header 4

and so on...

Avatar
Webdoc

6 October 2009 at 7:36am Community Member, 332 Posts

The header area must be in cms to edit before content. i understand that i need to add some lines in page.php under mysite but dont know what kind.

Avatar
Carbon Crayon

6 October 2009 at 7:51am Community Member, 598 Posts

Hi Webdoc

All you need to do is add an ImageField so that users can attach an image to the page. So to do that your Page class would look like this:

class Page extends SiteTree {
   
   public static $has_one = array(
      'BannerImage' => 'Image'
   );
   
   function getCMSFields() {
      $fields = parent::getCMSFields();
      
      $fields->addFieldToTab('Root.Content.Main', new ImageField('BannerImage', 'Banner image'),'Content');   

   return $fields;   
   }   
}

Then in your template you can use $BannerImage to call the image or <% control BannerImage %>$CroppedImage(20,20).URL<% end_control %> etc. etc.

Hope that helps

Aram

Avatar
Webdoc

6 October 2009 at 7:56am Community Member, 332 Posts

almost aram but im using flash embed code so image is not right.

Avatar
Carbon Crayon

6 October 2009 at 8:02am Community Member, 598 Posts

When you say flash embed code are you using SWFs? if so I tend to use a FileIFrameField instead of an ImageField and 'File' instead of 'Image'

Avatar
Webdoc

6 October 2009 at 8:03am Community Member, 332 Posts

but how i set the size of it

Avatar
Webdoc

6 October 2009 at 8:03am Community Member, 332 Posts

can u help with sample code please

Avatar
Carbon Crayon

6 October 2009 at 8:04am Community Member, 598 Posts

Surely the size is set in the embed code?

basically you are going to be using the CMS to set the URL of the flash object, the size will be hard coded into the template flash code, or am I missing something?

Go to Top