Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Blog Module /

Discuss the Blog Module.

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

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


Reply


2 Posts   1165 Views

Avatar
sdbruder

Community Member, 4 Posts

19 November 2009 at 8:29am

Edited: 19/11/2009 10:37am

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

Avatar
sdbruder

Community Member, 4 Posts

19 November 2009 at 10:35am

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