Login | Forgot password | Register
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.
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 |
-
Associating DataObjects to Subsite

28 June 2009 at 4:30am
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!
-
Re: Associating DataObjects to Subsite

28 June 2009 at 12:17pm
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 pagesSo, 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.
-
Re: Associating DataObjects to Subsite

5 July 2009 at 4:18am
Thanks a lot, this worked! Maybe this could be added to the Wiki ...
-
Re: Associating DataObjects to Subsite

12 August 2009 at 4:06am
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


