Jump to:

3429 Posts in 1057 Topics by 734 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Managing DateObjects within DateObjects

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

Page: 1
Go to End
Author Topic: 630 Views
  • jondbaker
    Avatar
    Community Member
    19 Posts

    Managing DateObjects within DateObjects Link to this post

    I'd like to create a page that displays links organized by categories. The current structure I have setup is LinkCategoryHolder(the actual page), LinkCategory, and Link, whereas LinkCategory and Link are both extensions of DataObject. Ideally, what I'd like to do is be able to click the Links(LinkCategoryHolder.php) page in the CMS, and then add display the different LinkCategories as tabs under Content. When clicking a particular LinkCategory tab, it would bring up a table of Links, and also present the ability to add new ones via the popup interface.

    For the templates, I would just set up a control for the different LinkCategories, and then a control for Links inside of that.

    Is this possible in the way that I'm describing, or would it be more easier if I were to just extend ModelAdmin and create a new menu link? Or is there an even easier way? It makes more sense to include it under the content of the page, but this designer has hit a road block.

    LinkCategoryHolder.php

    <?php
    class LinkCategoryHolder extends Page {
    static $singular_name = 'Link Category overview';
    static $plural_name = 'Link Category overviews';
    static $db = array(
    'Headline' => 'Text',
    );
    static $has_many = array(
    'LinkCategories' => 'LinkCategory'
    );
    }
    class LinkCategoryHolder_Controller extends Page_Controller {}
    ?>

    LinkCategory.php

    <?php
    class LinkCategory extends DataObject {
    static $singular_name = 'Link Category';
    static $plural_name = 'Link Categories';
    static $db = array(
    'Category' => 'Text'
    );
    static $has_many = array(
    'Links' => 'Link'
    );
    static $has_one = array(
    'LinkCategoryHolder' => 'LinkCategoryHolder'
    );
    }
    ?>

    Link.php

    <?php
    class Link extends DataObject {
    static $db = array(
    'LinkURI' => 'Text',
    'LinkDisplayText' => 'Text'
    );
    static $singular_name = 'Link';
    static $plural_name = 'Links';
    static $has_one = array(
    'LinkCategory' => 'LinkCategory'
    );
    }
    ?>

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