10448 Posts in 2223 Topics by 1719 members
| Go to End | Next > | |
| Author | Topic: | 4356 Views |
-
Re: News module or extension

2 March 2011 at 4:22pm
Makes sense - have added them as bugs on the github page @ https://github.com/nyeholt/silverstripe-news/issues
-
Re: News module or extension

24 August 2011 at 10:39am
Hey Marcus , trying out your news module (very nice work btw) . The main reason i am using the module is i need to automatically archive / file news articles by their published date. I am trying to create a latest news function that would pull the latest 5 published news articles and display them on the home page. I modified the function from the ss tutorial 2 but it doesn't seem to be pulling any records . Could you give me any pointers on how to achieve this? The code for the function is below
function LatestNews($num=5) {
$news = SiteTree::get_by_link('news');
return ($news ) ? DataObject::get("NewsArticle", "ParentID = $news ->ID", "OriginalPublishedDate DESC", "", $num) : false;
}Thanks
-
Re: News module or extension

24 August 2011 at 10:54am Last edited: 24 August 2011 10:54am
Mindfusion, This is the code I used to get the 2 most recent on the home page...so it shouldn't be hard at all to get 5 like you need:
function LatestNews($num=2) {
$news = DataObject::get("NewsArticle","","OriginalPublishedDate DESC","",$num);
return $news;
}
and yes, I am using this same module so it should be a simple copy/paste for you, then change the $num=2 to $num=5. -
Re: News module or extension

15 November 2011 at 3:23am
Hi,
Congrats for the module, works fine and just what I needed. One suggestion though:
While on a NewsArticle page, I'd like to have a list with other articles in a sidebar.
If I'm not the only one here, isn't it useful to add a method to the NewsArticle class that pulls out other articles with the method you described above?Now, I'm subclassing the NewsArticle class just for this method:
class MyCustom_NewsArticle extends NewsArticle {
public static $icon = 'news/images/newspaper';
public static $db = array();
public static $has_one = array();public function Articles() {
$holder = new NewsHolder();
return $holder->Articles();
}}
class MyCustom_NewsArticle_Controller extends Page_Controller {
}But that kinda pollutes my Pagelist (to choose from) with another Page type, and NewsArticle alone just looks fine (And easier to explain to future users of my client).
Well, maybe there's another way, I just started with SilverStripe ;)Ronald
-
Re: News module or extension

28 December 2011 at 10:12am
Hi,
I tried the module and it is really great. But I want to show the news on homepage. I see the code you use but I don't know where to paste these codes. If you can help me, I will be very glad. Thanks...
-
Re: News module or extension

28 December 2011 at 10:17am
If you are referencing my code, you can place it in your custom HomePage.php (I always put it in the Controller). Or you can put that code in the Page.php so you can actually access the news from anywhere in your site since most of your custom pages (if you have custom pages) will extend Page.php.
-
Re: News module or extension

17 August 2012 at 6:32pm
Does this work with ss3? i copied the code in the customehomepage.php but still cant see the latest news on the page
any help pls..
| 4356 Views | ||
| Go to Top | Next > |






