Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Blog Module /

Discuss the Blog Module.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Blog entries on main homepage.


Go to End
Reply


23 Posts   6446 Views

Avatar
Ultimate

Community Member, 18 Posts

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?

Avatar
lawless

Community Member, 33 Posts

31 July 2009 at 2:16pm

Edited: 31/07/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.

Avatar
Aioli

Community Member, 10 Posts

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.

Avatar
Aioli

Community Member, 10 Posts

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)?

Avatar
Willr

Forum Moderator, 5513 Posts

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;

Avatar
roterl

Community Member, 44 Posts

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.

Avatar
Willr

Forum Moderator, 5513 Posts

2 September 2009 at 9:57am

Sure can. You can try in the template -

<% control Page(blog) %>
<% control BlogEntries(2) %>
....
<% end_control %>
<% end_control %>

Go to Top