Jump to:

7938 Posts in 1540 Topics by 945 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » DataObjectmanager - Display File Frontend

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 1230 Views
  • merrick_sd
    Avatar
    Community Member
    95 Posts

    DataObjectmanager - Display File Frontend Link to this post

    There doesn't seem to be anything about how to display my .pdf on the frontend in the docs

    http://doc.silverstripe.org/modules:dataobjectmanager
    unless I'm missing something

    Resource.php
    class Resource extends DataObject
    {
       static $db = array (
          'Name' => 'Text',
          'Description' => 'Text',
          'Category' => "Enum('Brochure, EPC, HIPS, FloorPlan')"
       );
       
       static $has_one = array (
          'Attachment' => 'File',
          'HousePage' => 'HousePage'
       );
       
       public function getCMSFields_forPopup()
       {
          return new FieldSet(
             new TextField('Name'),
             new TextareaField('Description'),
             new DropdownField('Category','Category', singleton('Resource')->dbObject('Category')->enumValues()),
             new FileIFrameField('Attachment')
          );
       }
    }

    Housepage.php

    static    $db = array(
    ???

    ):
          static $has_many = array(
          'Bullets' => 'Bullet',
       'Rooms' => 'Room',
       'Resources' => 'Resource',
       'ImageAttachments' => 'ImageAttachment'

       );

          function getCMSFields() {
             $fields = parent::getCMSFields();
             
             
             
             $manager = new FileDataObjectManager(
             $this, // Controller
             'Resources', // Source name
             'Resource', // Source class
             'Attachment', // File name on DataObject
             array(
                'Name' => 'Name',
                'Description' => 'Description',
                'Category' => 'Category'
             ), // Headings
             'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
             // Filter clause
             // Sort clause
             // Join clause
          );
    $fields->addFieldToTab("Root.Content.Resources",$manager);

    .ss FRONT Page

    <% if Resources %>
    <ul>
    <% control Resources %>

    <li>$Name $File ?guess </li>
    <% end_control %>
    </ul>
    <% end_if %>

    does anyone have any ideas

  • UncleCheese
    Avatar
    4085 Posts

    Re: DataObjectmanager - Display File Frontend Link to this post

    $Attachment.URL

  • merrick_sd
    Avatar
    Community Member
    95 Posts

    Re: DataObjectmanager - Display File Frontend Link to this post

    Thanks a million.

    Its so easy when you know how. I was trying just $Attachment and all sorts.

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