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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Diffrent Header Image For Each Page?


Reply

5 Posts   1352 Views

Avatar
FireMe!

15 July 2009 at 6:36am Community Member, 74 Posts

Hi
What I am after doing is have a different header image for each page so i noticed this topic http://www.silverstripe.org/template-questions/show/254016#post254016 and Aram has put a post of a good way to do it but i can not seem to get it to work, Aram can you help me :-)

Here is the code

Page.php

class Page extends SiteTree {

public static $db = array(
);

public static $has_one = array(
);

static $has_one = array (
'HeaderImage' => 'Image'
);

function getCMSFields() {

$fields = parent::getCMSFields();

if(!$this->Parent){
$fields->addFieldToTab("Root.Content.Main", new ImageField('HeaderImage'));
}

return $fields;
}

}

page.ss

<% control Level(1) %>
$HeaderImage
<% end_control %>

I seem just to get a blank white screen, I bet is something simple.

Thanks in advance

FireMe

Avatar
Hamish

15 July 2009 at 9:04am Community Member, 712 Posts

The control statement takes you out of the current page. Remove the control and leave the $HeaderImage - should work fine.

Avatar
FireMe!

16 July 2009 at 4:55am Community Member, 74 Posts

Thanks for the reply Hamish, but I still seem to be getting a white screen> :-(

Avatar
AdamJ

16 July 2009 at 2:42pm Community Member, 145 Posts

Where are you getting a white screen? In the admin?

I don't know if SS will have an issue with it, but your defining has_one twice.

Avatar
FireMe!

17 July 2009 at 4:20am Community Member, 74 Posts

the white screen is every where on the site