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: 3999 Views
  • Webdoc
    Avatar
    Community Member
    332 Posts

    Re: Help with header Link to this post

    U wanna have tab where u can change the banner image in everypage??

  • steve_nyhof
    Avatar
    Community Member
    224 Posts

    Re: Help with header Link to this post

    Thank you for the reply, I have this all working now.

  • HanSolo
    Avatar
    Community Member
    83 Posts

    Re: Help with header Link to this post

    Hi used the

    public static $has_one = array(
    'FlashBanner1' => 'File'
    );

    function getCMSFields() {
    $fields = parent::getCMSFields();

    $fields->addFieldToTab('Root.Content.Banner', new FileIFrameField('FlashBanner1'));

    return $fields;
    }
    }
    in mysite/code/page.php
    but when i try to acccess the cms i get website error. Have I missed something

    Joakim

  • Martijn
    Avatar
    Community Member
    271 Posts

    Re: Help with header Link to this post

    What error?

    I got a cant handle suburls when using SiteTree::enable_nested_urls(); in 2.4.

    Diable the nested urls made the uploadfield work again.
    Edit:: this is nog a nested_urls related error, but a translatable error...

  • steve_nyhof
    Avatar
    Community Member
    224 Posts

    Re: Help with header Link to this post

    This is my code in the code>Page.php file

    class Page extends SiteTree {

    public static $db = array(
    );

    public static $has_one = array(
    "HeaderImage" => "Image"
    );

    function getCMSFields() {
    $fields = parent::getCMSFields();
    $fields->addFieldToTab("Root.Content.Main", new ImageField("HeaderImage", "Header Image"));

    return $fields;
    }

    }

  • HanSolo
    Avatar
    Community Member
    83 Posts

    Re: Help with header Link to this post

    I used the same code but still an error. I checked the error log on the server and it said that the editor.css was missing, so I took it from the blackcandy template and moved it over to the server but still the same error?

    Joakim

  • Chrisazuka
    Avatar
    Community Member
    20 Posts

    Re: Help with header Link to this post

    Hello Aram,

    You tip on the unique header image for pages has really help me alot. In continuation of puting unique Image or Flash header, I will really appreciate if you can help me with how i can upload not just 1 image but multiple images for each page and use the images in a with this javascript image slider: http://www.gruppo4.com/~tobia/cross-slide.shtml (CrossSlide is a jQuery plugin for image animation slideshow)

    I have tried to use the javascript code directly inside the template but didn't work, the image or how i can use it directly with the image gallery module which seems like further maths to me, very dificult. I have very new with SilverStripe, great product.

    What i want to achieve is unique/ different Image slideshow on the Header of my pages, the diffrent pages will have diffrent image header slider.

    Please any help will be appreciated from you guys, expecially with using the CrossSlide javascript image slider: http://www.gruppo4.com/~tobia/cross-slide.shtml (Ken Burns effect)

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Help with header Link to this post

    Hi Crisazuka

    This plugin seems to be a bit unconventional in that it defines the image locations within the script itself...not really a great way to do it but anyway.....

    To get it to work you will need to define the script from within the init() function of your Page_Controller class. You can then get the URLs of the images you have defined in the $has_one relationship.

    e.g.:

       public function init() {
          parent::init();
                
          Requirements::javascript("http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js");
    Requirements::javascript("mysite/javascript/jquery.cross-slide.js");
          Requirements::customScript("
             jQuery('#test1').crossSlide({
              speed: 45,
              fade: 1
             }, [
              { src: '" . $this->Image1()->URL . "', dir: 'up' },
              { src: '" . $this->Image2()->URL . "', dir: 'down' },
              { src: '" . $this->Image3()->URL . "', dir: 'up' },
              { src: '" . $this->Image4()->URL . "', dir: 'down' }
             ]);      
          ");         

       }

    }

    To make it work with a $has_many relationship (i.e. an Image Dataobject manager) would be a little more complicated, basically you would need to create a loop to loop through each of the images and define the path which given the structure of the definition isn't immediately obvious, I think you would need to generate the definition with a function and then insert it into the page....probably more hassle than it's worth

    Anyway I hope that helps

    Aram

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