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.

General Questions /

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

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

Diffrent Header Image For Each Page?


Go to End


5 Posts   1902 Views

Avatar
FireMe!

Community Member, 74 Posts

15 July 2009 at 6:36am

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

Community Member, 712 Posts

15 July 2009 at 9:04am

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

Avatar
FireMe!

Community Member, 74 Posts

16 July 2009 at 4:55am

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

Avatar
AdamJ

Community Member, 145 Posts

16 July 2009 at 2:42pm

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!

Community Member, 74 Posts

17 July 2009 at 4:20am

the white screen is every where on the site