7938 Posts in 1466 Topics by 943 members
|Go to End||Next >|
12 April 2009 at 10:33am
@mr_t - I see what you're getting at, but I think it's a little too far out of scope of the project for me to develop right now. DataObjectManager was built as an extension to the ComplexTableField, so I'd like the functionality to stay parallel for now.
@everyone who has been trying to fix the FileDataObjectManager on a page issue -- I'm having a hard time replicating this problem. Here's what I've done.
I've created a has_many relation on my Page class to the example Resource object. Resource has_one Page. In my Page class, I have a FileDataObjectManager for Resources, and I setParentClass("Page");
I'm able to get every page to have its own resources. What am I missing?
12 April 2009 at 10:52am Last edited: 12 April 2009 10:53am
@ UncleCheese I really can't say as I have been unable to reproduce the problem myself. But I did post a theory a few posts back. Do you have your DataObject sortable? That forces the ID into the DB and I believe solves any issues the others are mentioning. See my previous post here:
Ok, this is just a theory, but I am pretty sure it is why my code works with out setting the parent class, or any of the other hoops.
SortableDataObject::add_sortable_class('SomeDataObject'); (goes in your _config.php)
This insures you have IDs and maybe this is what make's mine work? I just know that I get all these things for free that people are saying don't work. Anyway, hope this helps someone.
Just a thought.
12 April 2009 at 11:24am
UncleCheese the issue is not with the Page class itself. Make a subclass of Page (say Page2). No need to add any db field or relationship for that class. Now when you try to add a Resource object to a Page2 class page, the resource will not stick to that page. PageID is set to 0. The issue is always related to a subclass of Page.
Drye we have always had the related dataobjects sortable and it makes no difference.
12 April 2009 at 11:26am Last edited: 12 April 2009 11:27am
Its where you have a page two levels down from the root in the menu structure:
Brands :: Works fine
Brands -> Gucci :: Works Fine
Brands -> Gucci -> Watch :: Stops working here
So if you look at the attachment its at the Watch level where commenting out that line fixes the issue
12 April 2009 at 11:57am
Well I don't have any pages 3 levels deep using the DataObjectManager. But all of my 1 and 2 level Page subclasses seem to work. They each have there own data and do not display the data of other pages.
UncleCheese good luck with this one, I'm afraid I can offer no more.
13 April 2009 at 3:33pm
Hey, guys, I've fixed this bug. For those of you who hacked the code, please revert your changes and check out the new version to avoid conflicts in the future.
The problem was that FileDataObjectManager was erroneously using the controller to create the $ownerID field. It introspectively searches the has_many array of the controller class to find the relation name. Most of the time, the controller is passed as $this, which creates a problem. Take this example:
class Page extends SiteTree
static $has_many = array ('FileObjects' => 'FileObject');
class FileObject extends DataObject
static $has_one = array ('Page' => 'Page');
class SubPage extends Page
In the SubPage class, the controller $this will return a SubPage object. The has_many array search will return null in this case, so no $ownerID field is ever set.
The fix was to use the member method ComplexTableField::getParentIDName() to generate this fieldname correctly. It's still necessary to use the setParentClass method in this case, however. It's used in ComplextTableField for exactly this scenario, but it wasn't being taken advantage of since getParentIDName() wasn't being used.
13 April 2009 at 4:29pm
A little off topic..
Do you have a downloadable example of http://doc.silverstripe.com/doku.php?id=modules:swfuploadfield so I can look at the code. Having a number of issues trying to get this to work - I think if i can see how the working version is setup this will shed some light on where Ive gone wrong.
I saw this (http://www.silverstripe.org/archive/show/229938#post229938) but it still does not answer my questions. I'm a bit of a noob so its probably simple stuff. Would just like to see how its setup in the php file / front end.
13 April 2009 at 4:56pm
When adding file objects, how do you remove the "Upload from my computer" and "Upload ..." button from the pop up? We need to force the user to only import from an existing folder and to avoid confusion, need to completely remove the "Upload from my computer" section above. What should be changed in the code?
|Go to Top||Next >|