1776 Posts in 498 Topics by 533 members
Blog Module
SilverStripe Forums » Blog Module » How to get "the latest N Blog entries except $THATID"? (RESOLVED)
Discuss the Blog Module.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 848 Views |
-
How to get "the latest N Blog entries except $THATID"? (RESOLVED)

19 November 2009 at 8:29am Last edited: 19 November 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 ...
-
Re: How to get "the latest N Blog entries except $THATID"? (RESOLVED)

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 { ....
| 848 Views | ||
|
Page:
1
|
Go to Top |

