WPP-Public/akqa-nz-silverstripe-versioneddataobjects

i do not see the drafts in the CMS

Closed this issue · 2 comments

Hi,
First of all thank you for this extension.
I installed it but in the CMS I get only the published records i do not see the drafts in the gridfield any idea on what i'm doing wrong?

Thanks
Rob

Hi Rob, do the draft records show up when you switch the site to viewing draft (tack ?stage=Stage on the end of the URL)? If so, this is a known issue that comes from SilverStripe's Versioned data extension modifying all database queries based on a global "reading mode" state by default.

Depending on the context, the solution differs:

  • If you have control over the query, you can alter the behaviour of Versioned with dataquery parameters to override the global setting:

    VersionedFoo::get()
      ->setDataQueryParam(['Versioned.stage' => 'Stage']);
  • If you can't modify the query, you can use VersionedReadingMode from this module to change and restore the global reading mode:

    VersionedReadingMode::setStageReadingMode();
    
    // ... code that runs queries
    
    VersionedReadingMode::restoreOriginalReadingMode();
  • If you need a model admin to manage versioned dataobjects, you can use VersionedModelAdmin from this module in place of ModelAdmin

Thank you that worked great!, i did not know that the ?stage=Stage worked in the admin.

I used the
VersionedFoo::getList()
->setDataQueryParam(['Versioned.stage' => 'Stage']);
and it works like a charm.

Thank you so much