7912 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » 2.4 - DOM in SiteConfig not working for me
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
| Go to End | ||
| Author | Topic: | 4967 Views |
-
Re: 2.4 - DOM in SiteConfig not working for me

6 September 2010 at 10:25pm
In Site Config, do you still need to use;
$manager->setParentClass('SiteConfig');
$manager->setSourceID($this->owner->ID);or is it just;
$manager->setParentClass('SiteConfig');
What about if using it from another object decorator?
-
Re: 2.4 - DOM in SiteConfig not working for me

7 September 2010 at 1:39am
Probably not. If you have a corresponding $has_many and $has_one, you shouldn't need any of that. Maybe the sourceID() call.. cause I know SiteConfig is a bit of a different animal.
-
Re: 2.4 - DOM in SiteConfig not working for me

4 January 2012 at 12:55am
For your information, I had to add the setSourceID call for this to work.
Thanks again, UncleCheese!
-
Re: 2.4 - DOM in SiteConfig not working for me

22 February 2012 at 10:02pm
The solution offered in this topic works for me, but somehow not totally:
In my customsiteconfig.php i have this code:
$manager = new DataObjectManager(
$this->owner,
'Quotes',
'Quote',
array(
'Quote' => 'Quote'
),
'getCMSFields_forPopup'
);
$manager->setSourceID($this->owner->ID);
$manager->setParentClass('SiteConfig');
$fields->addFieldToTab("Root.Quotes",$manager);Then, in my Quote.php i have:
class Quote extends DataObject
{
static $db = array (
'Quote' => 'HTMLText'
);static $has_one = array (
'SiteConfig' => 'SiteConfig'
);public function getCMSFields_forPopup()
{
return new FieldSet(
new SimpleHTMLEditorField('Quote','Quote')
);
}
}I use this on a multilanguage site, so in my _config.php i have:
Object::add_extension('SiteConfig', 'Translatable');At first, the dataobjectmanager loads the items for the language that has been selected. When I click the "add quote" button and click away or save, the dataobjectmanager loads the items for the default language. Somehow, it loses the reference to the loaded siteconfig. Does anyone else have troubles with DOM in CustomSiteConfig with multiple languages?
-
Re: 2.4 - DOM in SiteConfig not working for me

22 February 2012 at 10:26pm
it seems the siteconfig and locale stuff doesn't work very well. I hacked the DataObjectManager class in the following way, and now it works:
public function Link($action = null)
{
return Controller::join_links(parent::Link($action),'?'.$this->getQueryString()."&locale=".Translatable::get_current_locale());
}
public function BaseLink()
{
return parent::Link()."&locale=".Translatable::get_current_locale();
} -
Re: 2.4 - DOM in SiteConfig not working for me

2 March 2012 at 2:14am
I'm currently having a battle with SiteConfig ...
FYI: I found that I had to do what Juanitou did and also add "$manager->setSourceID($this->owner->ID);" to get a complete solution: add items, retrieve component set.
Without the setSourceID() call, any query on a 'has_many' set (i.e. SiteConfig::current_site_config()->MyHasManyItems()) would return an empty ComponentSet; even though in the CMS I could see all the items.
J.
-
Re: 2.4 - DOM in SiteConfig not working for me

22 January 2013 at 5:01am Last edited: 22 January 2013 5:20am
Sorry for pulling this thread up, but what is the final piece of code to make DOM work on a siteconfig using SS 2.4.9 and the latest DOM from github? See my attempt which doesn't work: http://paste2.org/p/2782785
Update works now: http://paste2.org/p/2782858
| 4967 Views | ||
| Go to Top |


