Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Resolved [ Create page to display additional details field ]

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: 591 Views
  • bunheng
    Avatar
    Community Member
    77 Posts

    Resolved [ Create page to display additional details field ] Link to this post

    Hi There,

    I am using FileDataObjectManager to create my Resources Page and announcement page.
    Is it to possible to create another page to enable visitor to click and see more details for each resource.

    On ResourcePage.ss I just display a little information, I want them to click on title and direct to a new page which display only one record with all additional detail information.

    Your I really appreciated.

    Bunheng

    --------------------------
    Rsource.php
    --------------------------

    class Resource extends DataObject {

    static $db = array(
    'Title' => 'Text',
    'Description' => 'HTMLText',
    'Date' => 'Date'
    );
    static $has_one = array(
    'ResourcePage' => 'ResourcePage',
    'ResourceFile' => 'File'
    );
    static $singular_name = "Resource";
    static $plural_name = "Resources";

    function getCMSFields() {
    $fields = new FieldSet(
    new TextField('Title', 'Title'),
    new SimpleHTMLEditorField('Description', 'Description'),
    new FileUploadField('ResourceFile', 'Addional Information'),
    new DatePickerField('Date', 'Released Date')
    );
    return $fields;
    }

    }
    -----------------------------
    ResourcePage.php
    -----------------------------
    class ResourcePage extends Page {

    static $icon = "";
    static $db = array();
    static $has_one = array();
    static $has_many = array(
    'Resources' => 'Resource'
    );
    static $singular_name = "Resource Page";
    static $plural_name = "Resource Pages";
    function getCMSFields(){
    $myfields = parent::getCMSFields();
    $mytable = new FileDataObjectManager(
    $this,
    'Resources',
    'Resource',
    'ResourceFile',
    array(
    'Title' => 'Title',
    'Description' => 'Description',
    'Date' => 'Date'
    )
    );
    $myfields->addFieldToTab('Root.Content.Resources', $mytable);
    return $myfields;
    }

    }
    class ResourcePage_Controller extends Page_Controller{

    }

    ------------------------------
    ResourcePageHolder.php
    ----------------------------------

    class ResourcePageHolder extends Page {

    static $db = array();
    static $allowed_children = array('RsourcePage');
    static $singular_name = 'RsourcePage';
    }
    class ResourcePageHolder_Controller extends Page_Controller {

    }

    -----------------------------------
    ResourcePage.ss
    -----------------------------------
    <div class="typography">
    <h1>$Title</h1>
    <% if Resources %>
    <% control Resources %>
    <div id="announcelist">
    <ul>
    <li class="title"><b><a href="$Link">$Title</a></b></li>

    <li>$Description</li>
    <li class="details">
    <a href="$ResourceFile.Link"><b>Download Detail</b></a>
    <% if Date %>
    <span class="listdate"> Expiry Date: $Date.Nice</span>

    <% end_if %>
    </li>

    </ul>
    <% end_control %>
    <% else %>
    <p>There is no record.</p>
    <% end_if %>
    </div>
    </div>

  • UncleCheese
    Avatar
    4085 Posts

    Re: Resolved [ Create page to display additional details field ] Link to this post

    This has been written up a number of times.. I'd probably start here: http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-1-keeping-it-simple/

    --------------------
    SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

  • bunheng
    Avatar
    Community Member
    77 Posts

    Re: Resolved [ Create page to display additional details field ] Link to this post

    Good morning,

    I have been looking for this kind tutorial
    I really appreciate your kindness advice and contribution.

    My Best Regards,
    Bunheng

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