Jump to:

1851 Posts in 1606 Topics by 561 members

Blog Module

SilverStripe Forums » Blog Module » Blog entries on main homepage.

Discuss the Blog Module.

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

Page: 1 2 3
Go to End
Author Topic: 6173 Views
  • Ultimate
    Avatar
    Community Member
    18 Posts

    Re: Blog entries on main homepage. Link to this post

    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?

  • lawless
    Avatar
    Community Member
    33 Posts

    Re: Blog entries on main homepage. Link to this post

    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.

  • Aioli
    Avatar
    Community Member
    10 Posts

    Re: Blog entries on main homepage. Link to this post

    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.

  • Aioli
    Avatar
    Community Member
    10 Posts

    Re: Blog entries on main homepage. Link to this post

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

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: Blog entries on main homepage. Link to this post

    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;

  • roterl
    Avatar
    Community Member
    44 Posts

    Re: Blog entries on main homepage. Link to this post

    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.

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: Blog entries on main homepage. Link to this post

    Sure can. You can try in the template -

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

    6173 Views
Page: 1 2 3
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.