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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Help with header


Go to End


24 Posts   6232 Views

Avatar
Webdoc

Community Member, 349 Posts

6 October 2009 at 5:49am

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

Community Member, 349 Posts

6 October 2009 at 7:36am

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

Community Member, 598 Posts

6 October 2009 at 7:51am

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

Community Member, 349 Posts

6 October 2009 at 7:56am

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

Avatar
Carbon Crayon

Community Member, 598 Posts

6 October 2009 at 8:02am

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

Community Member, 349 Posts

6 October 2009 at 8:03am

but how i set the size of it

Avatar
Webdoc

Community Member, 349 Posts

6 October 2009 at 8:03am

can u help with sample code please

Avatar
Carbon Crayon

Community Member, 598 Posts

6 October 2009 at 8:04am

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