Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Reading of Live pages in CMSMain

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1
Go to End
Author Topic: 1247 Views
  • xmedeko
    Avatar
    Community Member
    94 Posts

    Reading of Live pages in CMSMain Link to this post

    Hi,

    if the user deletes the page in CMS, he/she can see the readonly version of the Live page. However, it the Page has some relationship (e.g. has_many) to another DataObjects and shows this objects in a tab in CMS, then DataObject::get() does not work well, because the Versioned::$reading_stage is not set to 'Live'. I made the following correction to the CMSMain.php. May it the break something?

    --- CMSMain.php.orig   2007-01-31 10:41:47.000000000 +1300
    +++ CMSMain.php   2007-07-02 12:26:26.000000000 +1200
    @@ -247,9 +254,15 @@
             $record = DataObject::get_one( $treeClass, "`$treeClass`.ID = $id");
             
             if(!$record) {
    -            $record = Versioned::get_one_by_stage($treeClass, "Live", "`$treeClass`.ID = $id");
    -            
    -            if($record) $record->DeletedFromStage = true;
    +//            $record = Versioned::get_one_by_stage($treeClass, "Live", "`$treeClass`.ID = $id");
    +            Versioned::reading_stage('Live');
    +            singleton($treeClass)->flushCache();
    +            $record = DataObject::get_one( $treeClass, "`$treeClass`.ID = $id");
    +            if($record) {
    +               $record->DeletedFromStage = true;
    +            } else {
    +               Versioned::reading_stage(null);
    +            }
             }
             return $record;

    Maybe better solution to Versioned::reading_stage('Live'); is
    Versioned::reading_stage(Versioned::get_live_stage());

  • Andy
    Avatar
    230 Posts

    Re: Reading of Live pages in CMSMain Link to this post

    Thanks, I've applied this to the 2.1 code.

    1247 Views
Page: 1
Go to Top

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

Comments on this website? Please give feedback.