Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Change Flash

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1614 Views
  • mschiefmaker
    Avatar
    Community Member
    187 Posts

    Change Flash Link to this post

    Hi

    I have a different Flash file for each of my pages (all of the same page type) but not in the content area - it is in a banner across the top.

    If it were an image I could do it by extending the page with

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

    Is there a way to do this for Flash i.e.
    static $has_one = array(
    'PhotoMontage' => 'Flash');

    Or am I barking up the wrong tree? Should I be doing it some other way?

    Thanks

    MM

  • jam13
    Avatar
    121 Posts

    Re: Change Flash Link to this post

    Image just extends File, so you can do:

    static $has_one = array(
    'PhotoMontage' => 'File'
    );

    An even simpler approach is to put all your flash files in the same asset folder, and then just use a Varchar to hold the filename - you don't even need a relationship in this case.

  • mschiefmaker
    Avatar
    Community Member
    187 Posts

    Re: Change Flash Link to this post

    Hey Jam13

    When I change to what you suggest

    class Page extends SiteTree {
       static $db = array(
       );
       static $has_one = array(
       'PhotoMontage' => 'File'
    );
    function getCMSFields() {
    $fields = parent::getCMSFields();
       
    $fields->addFieldToTab("Root.MyBannerImage", new ImageField("BannerImage"));
       
    return $fields;
    }

    I have in my Page.ss file

    <div id="Heropics">
       $PhotoMontage
    </div>

    I get the error "The website server has not been able to respond to your request."

    Any thoughts?

    Thanks

    MM

  • jam13
    Avatar
    121 Posts

    Re: Change Flash Link to this post

    I don't know whether using an ImageField for a File will work properly - I've no idea how it will behave when you upload a flash file. You should probably use either a FileField, or one of the FileTree fields (I forget the name off the top of my head, but you can check in the documentation).

    Assuming you have got the backend working and have associated a file with the page, you'll need to render the flash file in the appropriate html. Because it's not an image, SilverStripe doesn't know how to render it automatically. Something like:

    <embed height="200" width="300" type="application/x-shockwave-flash" wmode="transparent" src="$PhotoMontage.URL"/>

    Although I would actually recommend using SWFObject (http://code.google.com/p/swfobject/) for embedding Flash movies rather than this untested code snippet.

  • mschiefmaker
    Avatar
    Community Member
    187 Posts

    Re: Change Flash Link to this post

    Hi Jam13

    Thanks for your help ... in the end I took your original advice and set-up files up as var.

    Cheers

    MM

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