Jump to:

1840 Posts in 1598 Topics by 557 members

Blog Module

SilverStripe Forums » Blog Module » How to get "the latest N Blog entries except $THATID"? (RESOLVED)

Discuss the Blog Module.

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

Page: 1
Go to End
Author Topic: 1001 Views
  • sdbruder
    Avatar
    Community Member
    4 Posts

    How to get "the latest N Blog entries except $THATID"? (RESOLVED) Link to this post

    Im trying this:

    function BlogEntries($limit=4) {
    $Blog = DataObject::get_one('BlogHolder', "Name = '".$this->blogname."'");
    if ($Blog) {
    $highlight = DataObject::get("BlogEntry",
    "ParentID = $Blog->ID AND find_in_set('highlight',Tags)",
    "Date DESC", "", 1);
    if (!$highlight) {
    return DataObject::get("BlogEntry",
    "ParentID = $Blog->ID",
    "Date DESC", "", $limit);
    } else {
    return DataObject::get("BlogEntry",
    "ParentID = $Blog->ID AND NOT ID = $highlight->ID",
    "Date DESC", "", $limit);
    }
    } else {
    return false;
    }
    }


    EDIT: Any way to show code using monospaced font or something similar?

    But highlight->ID translates to nothing and the SQL spit it out as Couldn't run query: ....WHERE (ParentID = 1 AND NOT ID = ) AND ...

  • sdbruder
    Avatar
    Community Member
    4 Posts

    Re: How to get "the latest N Blog entries except $THATID"? (RESOLVED) Link to this post

    answering my own question (actually simon_w got it on IRC), worked as

    $destaque = DataObject::get_one("BlogEntry","ParentID = $Blog->ID AND find_in_set('destaque',Tags)", "Date DESC");
    if ($destaque) {
    return DataObject::get("BlogEntry",
    "ParentID = $Blog->ID AND NOT `SiteTree`.ID = $destaque->ID",
    "Date DESC", "", $limit);
    } else { ....

    1001 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.