21491 Posts in 5783 Topics by 2621 members
| Go to End | Next > | |
| Author | Topic: | 2020 Views |
-
Version History on Data Objects

2 June 2010 at 10:44pm
Just wondering, has anyone done this? If so, how? Do you just have to use the Versioned class? I know how to use that to make changes between Staged and Live, but not more detailed version history.
Cheers,
Mo
-
Re: Version History on Data Objects

3 June 2010 at 10:47pm
Hi.
You can use the Versioned decorator on any DataObject class. I have done this on a project where the data objects were managed back end. The tricky thing with versioned is always being aware of which state it's in, and requires a degree of control. Versioned has a variety of methods, including allVersions, which gives you history. Check out it's methods.
Mark
-
Re: Version History on Data Objects

3 June 2010 at 11:11pm
Ooo, cool. I was kind of hoping that this was the case, but wasn't sure.
Definitely going to be making use of this very shortly, should be interesting
.
How do you go about viewing a full version history of an object in the CMS though? Would you have to use ModelAdmin, or can you link it into a page version history somehow?
Cheers,
Mo
-
Re: Version History on Data Objects

4 June 2010 at 1:06pm
With using Versioned you would have to build your own way of displaying history. Or you could also check out the Moderatable module which I believe has nice tools built in to view versions http://open.silverstripe.org/browser/modules/moderation/trunk
-
Re: Version History on Data Objects

4 June 2010 at 8:50pm
If you want to see version history, you could have a look at what the CMS does, since it shows full version history. Alternatively, you could query xyz_versions yourself, or use methods in the Versioned decorator.
The Moderation module may be of use, but it's primary purpose is to allow moderation of data objects from the front end, and provides a moderation backend in the CMS. i.e. submitted data objects are kept in draft, and when approved become published, and visible to the front end. It has decorators for both versioned and unversioned database. The versioned variant is not for the faint-hearted
Mark
-
Re: Version History on Data Objects

4 June 2010 at 9:10pm
Doesn't Versioned::getAllVersions() (or whatever it is called) return a DataObjectSet? If so, it surely wouldn't be too difficult to get a version history of an object?
I guess it could be a pain to set up "restore" and "compare" functionality though.
Mo
-
Re: Version History on Data Objects

5 June 2010 at 11:41am
Yes, getAllVersions() returns a DataObjectSet of Versioned_Version objects, which I think contains the fields of the decorated data object plus what's in the _versions table. So it would be straightforward to get a history from that. It can be filtered too. I think you'll need to look at the CMS code if you want to do more fancy things like differences etc. It really depends on what you're trying to achieve.
Mark
-
Re: Version History on Data Objects

19 August 2010 at 10:29am
Hi Mark
I'm trying to work out how to put a filtered list of page versions which will appear in the filter when a CMS editor looks at the page.
AllVersions() looks promising and I've had a look at the documentation: http://api.silverstripe.org/2.4/sapphire/model/Versioned.html#methodallVersions
I started with this to get an idea of what would get returned:
class Page_Controller extends ContentController {
function PageVersions(){
$PageVersions = $this->AllVersions();
debug::show($PageVersions);
}But the debug just returns
Debug (Page_Controller->PageVersions() in line 93 of Page.php)
DataObjectSet# ViewableData_Debugger
# ViewableData_Debugger
# ViewableData_Debugger
# ViewableData_Debugger
...Any ideas where I'm going wrong?
Cheers
Tama
| 2020 Views | ||
| Go to Top | Next > |




