Login | Forgot password | Register

X

What is OpenID?

OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account.

With OpenID, your ID becomes a URL (e.g. http://username.myopenid.com/). You can get a free OpenID for example from myopenid.com.

For more information visit the official OpenID site.

Jump to:

4705 Posts in 895 Topics by 795 members

All other Modules

SilverStripe Forums » All other Modules » Associating DataObjects to Subsite

Discuss all other Modules here.

Page: 1
Go to End
Author Topic: Associating DataObjects to Subsite 484 Views
  • Hubertus
    avatar
    Community Member
    14 posts

    Associating DataObjects to Subsite Link to this post

    Hello,

    I wonder how to associate DataObjects to Subsites. Essentially, I would like to publish small "newsitems" (DataObjects) on my subsite that are specific to this subsite plus have the option to publish all or some of them on my main site (or any other subsite for that matter).

    Ideally, I'd be able to select what newsitem I want to show on my subsite's homepage through a DataObjectManager and have the same option for the homepage of my main site (select which of the many subsite's newsitems I want to show on the main site homepage).

    I'm also trying to have a Dropdown-Field in my getCMSFields_forPopup() function for the NewsItems that would list the available subsites and allow me to alter the relation and re-assign my NewsItem to another subsite.

    Any hints how this could be done are greatly appreciated!

  • Sam
    avatar
    Administrator
    649 posts

    Re: Associating DataObjects to Subsite Link to this post

    Right now there's no out-of-the-box way of doing this easily, however, a bit of copy'n'paste should get you what you want.

    The key to how this is done for the pages is subsites/code/SiteTreeSubsites.php. The critical pieces of code that are necessary for making something "subsite aware" are as follows:

    * extraStatics() - adds the SubsiteID field
    * augmentSQL() - filters the queries to only show items from the current subsite
    * First line of augmentBeforeWrite() - sets the subsite ID of newly created pages

    So, if you create a new decorator for your news item objects, and copy and paste those pieces of code into that.

    A sensible refactoring of the subsites module might be to have a 'parent decorator' that SiteTreeSubsites and others inherited from.

  • Hubertus
    avatar
    Community Member
    14 posts

    Re: Associating DataObjects to Subsite Link to this post

    Thanks a lot, this worked! Maybe this could be added to the Wiki ...

  • Hauke
    avatar
    Community Member
    2 posts

    Re: Associating DataObjects to Subsite Link to this post

    My english is bad and i am a newbie in Silverstripe.

    I want to select the subsites where the newsitems should published. Have you a tutorial for me?

    Thanks
    Hauke

    484 Views
Page: 1
Go to Top

Currently Online: craigm, Sean, Willr

Welcome to our latest member: jcamenisch

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.