1 <?php
2 3 4 5 6
7 class ExtendPageNews extends Extension {
8 function ShowNewsWidget($id = false, $limit = false) {
9 $limit = intval($limit);
10 if (!$limit) {
11 $sc = SiteConfig::current_site_config();
12 $limit = $sc->NewsOnHomePage;
13 }
14
15 $parentFilter = '';
16 if ($id = intval($id)) {
17 $parentFilter = "ParentID = $id AND";
18 }
19 else if ($id) {
20 $holder = DataObject::get_one('NewsHolder', "URLSegment='" . Convert::raw2sql($id) . "'");
21 $parentFilter = "ParentID={$holder->ID} AND";
22 }
23
24 return DataObject::get('NewsEntry', "$parentFilter Status LIKE '%Published%'", "Date DESC, ID DESC", '', $limit);
25 }
26
27
28 function ShowNewsCalendarWidget($id = false) {
29 if ($id = intval($id)) {
30 $holder = DataObject::get_by_id('NewsHolder', $id);
31 } else {
32 $holder = DataObject::get_one('NewsHolder');
33 }
34 if ($holder) return new NewsLiveCalendarWidget($holder);
35 return false;
36 }
37 }
38
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the
Silverstripe Forums to ask development related questions.
-