1770 Posts in 495 Topics by 531 members
Blog Module
SilverStripe Forums » Blog Module » Blog entries on main homepage.
Discuss the Blog Module.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
| Go to End | ||
| Author | Topic: | 5614 Views |
-
Re: Blog entries on main homepage.

29 July 2009 at 9:46am
Ok, nice thread for now. I've managed to get the latest two posts shown on my homepage. The problem is: I've activated WYSIWYG-editing in _config.php, but the LatestNews on my homepage just shows the raw content without any html-entities.
Any hints?
-
Re: Blog entries on main homepage.

31 July 2009 at 2:16pm Last edited: 31 July 2009 2:17pm
Ultimate, I ran into that same problem. I already had blog posts without the WYSIWYG editor enabled, then enabled it and got raw content. I just went back and edited the posts using the WYSIWYG editor and they were corrected.
Seems that by enabling WYSIWYG editing it changes the way the blog module parses the content.
BTW, big thanks to Mr. Hyde for the code snippet. Helped me out a lot.
-
Re: Blog entries on main homepage.

1 September 2009 at 2:14pm
Hi,
I have my 'blog/news' entries working on the home page but I have also included a 'Featured Project' on the home page. This is showing up but no matter what number i put in (I only want one project to show) it displays all projects on the homepage.
Here is my code:[ code]class HomePage_Controller extends Page_Controller {
function FeatureProject($num=1) {
$projects = DataObject::get_one("ProjectHolder");
return ($projects) ? DataObject::get("ProjectPage", "ParentID = $projects->ID", $num) : false;
}function LatestNews($num=1) {
$news = DataObject::get_one("ArticleHolder");
return ($news) ? DataObject::get("ArticlePage", "ParentID = $news->ID", [ color=yellow]"Date DESC", "",[ /color] $num) : false;
}}
[ /code]Is the "Date DESC", "", necessary? When i include it in FeatureProject it comes up with an error. I don't have a date on my projects - is this related?
Any help would be appreciated.
-
Re: Blog entries on main homepage.

1 September 2009 at 2:34pm
ok i've fixed that:
function FeatureProject($num=1) {
$projects = DataObject::get_one("ProjectHolder");
return ($projects) ? DataObject::get("ProjectPage", "ParentID = $projects->ID", "", "", $num) : false;
}just removed Date DESC without removing the quote marks!
BUT how could I make the Feature Project display a new project each time the home page loads (randomly)?
-
Re: Blog entries on main homepage.

1 September 2009 at 5:07pm
For displaying in a random order you can use the RAND() mysql function.
return ($projects) ? DataObject::get_one("ProjectPage", "ParentID = $projects->ID", "RAND()", "", $num) : false;
-
Re: Blog entries on main homepage.

2 September 2009 at 6:26am
The BlogHolder_Controller already have method for getting entries ( function BlogEntries($limit = 10) )
Is there any way to call this method from the home page (via the HomePagess, or via HomePage_Controller method) ??rotem.
-
Re: Blog entries on main homepage.

2 September 2009 at 9:57am
Sure can. You can try in the template -
<% control Page(blog) %>
<% control BlogEntries(2) %>
....
<% end_control %>
<% end_control %>
| 5614 Views | ||
| Go to Top |



