Is there a way to hide blog entries from the Latest Pages Widget? How/where would I go about doing this, if it is possible? Thanks!
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
Hi just replace the LatestPagesWidget.php's content with the following and see.
<?php
class LatestPagesWidget extends Widget {
static $db = array();
static $title = "Latest Pages";
static $cmsTitle = "Latest Pages";
static $description = "Shows the 5 latest pages to be added/edited on the site";
function LatestPages() {
$pages = DataObject::get('SiteTree', 'ClassName != `BlogEntry`', '`LastEdited` DESC', '', 5);
$return = new DataObjectSet();
foreach($pages as $page) {
$versioned = Versioned::get_version("SiteTree", $page->ID, $page->Version);
$author = Member::get_one("Member", "ID = " . (int)$versioned->AuthorID);
$return->push(new ArrayData(array('Page' => $versioned, 'Author' => $author)));
}
return $return;
}
}
I tried it (finally) but when I loaded the website I got this error:
Error
The website server has not been able to respond to your request
Your suggestion is the only thing I changed, and I flushed the cache just to be sure since that often saves me. Not this time. :( What should I try next?
try with this code
<?php
class LatestPagesWidget extends Widget {
static $db = array();
static $title = "Latest Pages";
static $cmsTitle = "Latest Pages";
static $description = "Shows the 5 latest pages to be added/edited on the site";
function LatestPages() {
$pages = DataObject::get('SiteTree', 'ClassName != "BlogEntry" AND ClassName != "BlogHolder"', '`LastEdited` DESC', '', 5);
$return = new DataObjectSet();
foreach($pages as $page) {
$versioned = Versioned::get_version("SiteTree", $page->ID, $page->Version);
$author = Member::get_one("Member", "ID = " . (int)$versioned->AuthorID);
$return->push(new ArrayData(array('Page' => $versioned, 'Author' => $author)));
}
return $return;
}
}