Jump to:

10931 Posts in 2614 Topics by 1810 members

All other Modules

SilverStripe Forums » All other Modules » Event Calendar + File Download

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 735 Views
  • sav_ss
    Avatar
    Community Member
    11 Posts

    Event Calendar + File Download Link to this post

    Hi All,

    I have the event calendar module installed, I like it very much and I would like to extend it a bit so that I can allow a file download associated with a calendar event (eg. Download a registration form). I have made the following changes and I need some help figuring out why they didn't work:

    CalendarEvent.php

    static $has_many = array (
    ...
    'Resources' => 'Resource'
    );


    My resource class is exactly as found at http://doc.silverstripe.org/modules:dataobjectmanager (excepting I included different categories).

    public function getCMSFields()
    {
    $f = parent::getCMSFields();
    ...
    $manager = new FileDataObjectManager(
    $this,
    'Resources',
    'Resource',
    'Attachment',
    array(
    'Name' => 'Name',
    'Description' => 'Description',
    'Category' => 'Category'
    ),
    'getCMSFields_forPopup'
    );
    $f->addFieldToTab("Root.Content.Files",$manager);
    return $f;

    }


    When I log onto the CMS the extra 'Files' tab is there for a calendar event as expected, I can go about choosing a file to upload and in list or grid view I can see the file once it's uploaded. The problem I have is (and this might be related to why I cant get the file to show up on the website) when I click on the file a new popup-type window shows with the darkened background but it displays a Silverstripe error:

    [User Error] Couldn't run query: SELECT "Resource"."ClassName", "Resource"."Created", "Resource"."LastEdited", "Resource"."Name", "Resource"."Description", "Resource"."Category", "Resource"."AttachmentID", "Resource"."ResourcePageID", "Resource"."ID", CASE WHEN "Resource"."ClassName" IS NOT NULL THEN "Resource"."ClassName" ELSE 'Resource' END AS "RecordClassName" FROM "Resource" WHERE ("ParentID" = '97') Unknown column 'ParentID' in 'where clause'

    It's got me buggered.
    I'm hoping I can display the file download on the website by modifying CalendarEvent.ss with:

    <% if Resources %>
    <ul>
    <% control Resources %>
    <li>$Name</li> // Need to know how to hyperlink here. $Attachment.URL ??
    <% end_control %>
    </ul>
    <% else %>
    <p>This calendar event has no attachments.</p>
    <% end_if %>


    I'm new at php and not entirely sure if that's the correct usage of a control block. I'm wondering,

    <% control Resources %>

    should fetch me an array of Resource objects? How can I find out what member attributes of Resource I can access?

    That's a rather long-winded description of the problem, I hope it's clear. Help at this stage would be much appreciated.

    Cheers!

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