Jump to:

10979 Posts in 2722 Topics by 1815 members

All other Modules

SilverStripe Forums » All other Modules » CMS Workflow installation problems

Discuss all other Modules here.

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

Page: 1 2 3 4 5 6
Go to End
Author Topic: 3564 Views
  • simon_w
    Forum Moderator
    471 Posts

    Re: CMS Workflow installation problems Link to this post

    Yes, the Embargo/Expiry module is deliberately simple. There are two ways to do this:

    1) Get the database to do everything. This will still show pages that are expired (that's just another clause to add to the Where clause) and wont show pages to those that should be able to see them, even when embargoed/expired. You could add that logic in, but then you're starting to just imitate the canView() method.

    function LatestNews($num=5) {
    $news = DataObject::get_one("ArticleHolder");
    return ($news) ? DataObject::get("ArticlePage", "Embargo > NOW() AND ParentID = ".$this->LatestNewsID(), "Date DESC", "", $num) : false;

    2) Get the canView() method to do all the processing. This adds a bit more of a load to PHP, as it will need to load more objects, but does handle all the logic nicely.

    function LatestNews($num=5) {
    $news = DataObject::get_one("ArticleHolder");
    if (!$news || !$news->exists()) {
    return false;
    $items = DataObject::get("ArticlePage", "ParentID = ".$this->LatestNewsID(), "Date DESC");
    $pages = array();
    if ($items) foreach ($items as $page) {
    if ($page->canView()) $pages[] = $page;
    if (count($pages) >= $num) break;
    return new DataObjectSet($pages);

    In case the code doesn't document itself enough, this gets all the possible ArticlePages, then adds them to an array until either all the pages have been looped through, or enough pages have been selected. Then a DataObjectSet ($items is also one of these) is created which contains these pages, and returned.

  • Junglefish
    Community Member
    104 Posts

    Re: CMS Workflow installation problems Link to this post

    Hi Simon

    Genius! I implemented the latter of your two options and that is perfect! Exactly what I was after.

    Thanks for your help,


Page: 1 2 3 4 5 6
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.