17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1824 Views |
-
Latest Pages Widget - Hide Blog

1 December 2008 at 7:35pm
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!
-
Re: Latest Pages Widget - Hide Blog

2 December 2008 at 3:46pm
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;
}
} -
Re: Latest Pages Widget - Hide Blog

4 December 2008 at 7:05pm
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? -
Re: Latest Pages Widget - Hide Blog

4 December 2008 at 8:05pm
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;
}
}
| 1824 Views | ||
|
Page:
1
|
Go to Top |


