Login | Forgot password | Register
What is OpenID?
OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account.
With OpenID, your ID becomes a URL (e.g. http://username.myopenid.com/). You can get a free OpenID for example from myopenid.com.
For more information visit the official OpenID site.
Blog Module
SilverStripe Forums » Blog Module » Q: Multiple blogs with latest post on HomePage
Discuss the Blog Module.
| Go to End | Next > | |
| Author | Topic: Q: Multiple blogs with latest post on HomePage | 1407 Views |
-
Q: Multiple blogs with latest post on HomePage

4 May 2009 at 9:19pm
I'll use blog module for news site. Since we don't have categories like in forum module. I had to create a Blog Holder for each section.
Now, i would like to display from each section latest blog posts on Home Page.
HomePage
|- blog holder 1 (section 1 of news)
|- blog holder 2 (section 2 of news)
....
|- blog holder n (section n of news)Applying http://www.silverstripe.org/blog-module-forum/show/254124#post254124 or http://www.silverstripe.org/blog-module-forum/show/258365#post258365 i'll get only entries from [blog holder 1].
Any idea to do this ?
THX
-
Re: Q: Multiple blogs with latest post on HomePage

11 May 2009 at 1:00am
this gave me the idea to create a widget to make this possible, I will start on it soon! would be nice to have such a thing ;)
-
Re: Q: Multiple blogs with latest post on HomePage

7 June 2009 at 4:12pm
As i wrote about a widget, I create a new widget to achieve this. Welcome to use it.
-
Re: Q: Multiple blogs with latest post on HomePage

12 June 2009 at 6:52pm
@Nivanka - I DL'd your widget. Works perfectly.
I used the blog module as just part of a bigger site - how can I get the latest post on the main 'static' homepage?
Any help much appreciated as I'm a complete noob.
-
Re: Q: Multiple blogs with latest post on HomePage

15 June 2009 at 11:21am
I would also like to know if there is a way, when showing multiple latest entries in the widget, to have the newest entry at the top of the list; oldest at the bottom. Currently it's the other way round and I can't seem to find any code governing the order.
-
Re: Q: Multiple blogs with latest post on HomePage

17 June 2009 at 7:54am Last edited: 17 June 2009 7:55am
For managing latest post of more blog holders you have to create for each holder a function like describe and extend it:
...
$news = DataObject::get_one('BlogHolder', "Title = '<name of blogholder>'")
...http://silverstripe.org/blog-module-forum/show/261584?start=0#post261590
-
Re: Q: Multiple blogs with latest post on HomePage

3 July 2009 at 1:16pm Last edited: 5 July 2009 4:02pm
Ok, I figured out how to swap the order of entries in the widget (newest top, oldest bottom), but despite setting it to show the 6 latest entries in the cms, all entries appear in the widget ie. more than 6.
Can anyone assist?
Here is the code:
<?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: Q: Multiple blogs with latest post on HomePage

5 July 2009 at 9:58pm
so do you want to show all the posts?
if so, edit the code like this
//get the blog posts as the parameters provided
function blogPosts(){
$posts = DataObject::get('BlogEntry', 'ParentID = ' . $this->Blog, 'Date DESC');
return $posts;
}
| 1407 Views | ||
| Go to Top | Next > |
Currently Online: SSadmin, Carolg, CodeGuerrilla , Euphemismus, pitsnipe, rgo, Sean, freenet, Willr
Welcome to our latest member: pitsnipe




