753 Posts in 310 Topics by 289 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1737 Views |
-
LatestBlogPost widget problem - Fixed

27 July 2009 at 10:13pm Last edited: 29 July 2009 7:15pm
I am using this widget and it works very well _except_ that it does not pick up the number of posts to show, as set in the cms.
Can anyone see why? Or perhaps help me hard-code a fixed number (avoiding calls to the db). I really need to get this fixed for the dogs' refuge site I built and everything I've tried results in whitepage or website error.
TIA
<?php
// LatestBlogPost Widget 0.0.1 for the SilverStripe Blog Module
// 07.06.2009
// By nivanka@whynotonline.com
// Save this and LatestBlogPost.ss to widget_latestblogpost/ and run "db/build".class LatestBlogPost extends Widget {
static $title = "Latest News";
static $cmsTitle = "Latest News";
static $description = "With this plugin you can show up the latest blog post from any blog set up on your website.";static $db = array(
"Blog" => "Int",
"NumberOfPosts" => "Int",
);//get the wanted data from the user
function getCMSFields(){
$blogs = DataObject::get('BlogHolder');
$blogsDD = array();
foreach($blogs as $blog)
$blogsDD[$blog->ID] = $blog->Title;return new FieldSet(
new DropdownField("Blog", "Select a Blog", $blogsDD, $this->Blog ),
new NumericField("NumberOfPosts", "Number of Posts")
);}
//get the blog posts as the parameters provided
function blogPosts(){
$posts = DataObject::get('BlogEntry', 'ParentID = ' . $this->Blog, 'Date DESC', $this->numberOfPosts);
return $posts;
}}
?>
-
Re: LatestBlogPost widget problem - Fixed

29 July 2009 at 7:14pm
Fixed thanks to Nivanka:
<?php
// LatestBlogPost Widget 0.0.2 for the SilverStripe Blog Module
// 28.07.2009
// By nivanka@whynotonline.com
// Save this and LatestBlogPost.ss to widget_latestblogpost/ and run "db/build".
// This module allows you to add a suggestion form field to your forms.class LatestBlogPost extends Widget{
static $title = "Latest Blog Post";
static $cmsTitle = "Latest Blog Post";
static $description = "With this plugin you can show up the latest blog post from any blog set up on your website.";static $db = array(
"Blog" => "Int",
"NumberOfPosts" => "Int",
);//get the wanted data from the user
function getCMSFields(){
$blogs = DataObject::get('BlogHolder');
$blogsDD = array();
foreach($blogs as $blog)
$blogsDD[$blog->ID] = $blog->Title;return new FieldSet(
new DropdownField("Blog", "Select a Blog", $blogsDD, $this->Blog ),
new NumericField("NumberOfPosts", "Number of Posts")
);}
//get the blog posts as the parameters provided
function blogPosts(){
$posts = DataObject::get('BlogEntry', 'ParentID = ' . $this->Blog, 'Date DESC', '' ,$this->NumberOfPosts);
return $posts;
}}
?>
-
Re: LatestBlogPost widget problem - Fixed

1 August 2009 at 3:37am
the latest build is available to download here http://open.whynotonline.com/latest-blog-post/
-
Re: LatestBlogPost widget problem - Fixed

4 May 2011 at 11:21am Last edited: 4 May 2011 11:22am
I'm having no luck with this widget and am wondering what I'm doing wrong. All I'm getting is a message that there are no blog posts available. I did update my PHP file with Nivanka's 28.07.2009 fix - which then crashed SilverStripe! And the link in the post above doesn't work any more. Have emailed Nivanka to no avail - can anybody offer any advice?
| 1737 Views | ||
|
Page:
1
|
Go to Top |



