Jump to:

22976 Posts in 11702 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » Diffrent Header Image For Each Page?

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

Page: 1
Go to End
Author Topic: 1268 Views
  • FireMe!
    Avatar
    Community Member
    74 Posts

    Diffrent Header Image For Each Page? Link to this post

    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

  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: Diffrent Header Image For Each Page? Link to this post

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

  • FireMe!
    Avatar
    Community Member
    74 Posts

    Re: Diffrent Header Image For Each Page? Link to this post

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

  • AdamJ
    Avatar
    Community Member
    145 Posts

    Re: Diffrent Header Image For Each Page? Link to this post

    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.

  • FireMe!
    Avatar
    Community Member
    74 Posts

    Re: Diffrent Header Image For Each Page? Link to this post

    the white screen is every where on the site

    1268 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.