Jump to:

3435 Posts in 1026 Topics by 866 members

Template Questions

SilverStripe Forums » Template Questions » Help with header

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

Page: 1 2 3
Go to End
Author Topic: 3998 Views
  • Webdoc
    Avatar
    Community Member
    332 Posts

    Help with header Link to this post

    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...

  • Webdoc
    Avatar
    Community Member
    332 Posts

    Re: Help with header Link to this post

    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.

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Help with header Link to this post

    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

  • Webdoc
    Avatar
    Community Member
    332 Posts

    Re: Help with header Link to this post

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

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Help with header Link to this post

    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'

  • Webdoc
    Avatar
    Community Member
    332 Posts

    Re: Help with header Link to this post

    but how i set the size of it

  • Webdoc
    Avatar
    Community Member
    332 Posts

    Re: Help with header Link to this post

    can u help with sample code please

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Help with header Link to this post

    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?

    3998 Views
Page: 1 2 3
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.