Blog headlines on homepage

edited July 2012 in Modules
I would like to know how it is possible to show the blog headlines on the homepage of my website. I use the default Fuelcms blog and the content of the homepage are in the views folder. Can someone helping me with this? Thank you.

Comments

  • edited 7:12AM
    Load in the fuel blog library;

    $this->load->module_library('blog','fuel_blog'); $posts = $this->fuel_blog->get_recent_posts();

    There's a few methods in there to get category posts or by date etc.
  • edited 7:12AM
    If you are using the 1.0 branch, you can simply do the following:
    $posts = $this->fuel->blog->recent_posts();
  • edited July 2012
    Thank you for your fast reply. I am using version 0.9.3.

    How can I load the code in the fuel blog libary? Paste the code in fuel\modules\blog\libraries\Fuel_blog.php ?
  • edited 7:12AM
    You should be able to use the $posts array returned by Lance's example above and loop through it in your home view or layout file. If it is done in the CMS, you can use the Dwoo templating syntax in your layout input field:
    http://www.getfuelcms.com/user_guide/parsing
  • edited 7:12AM
    When I place the code from Lance in the home view I get the following error:

    A PHP Error was encountered
    Severity: Notice
    Message: Undefined property: MY_Loader::$fuel_blog
    Filename: views/home.php
    Line Number: 64

    Fatal error: Call to a member function get_recent_posts() on a non-object in E:\server\xampp\htdocs\fuelfmm\fuel\application\views\home.php on line 64
  • edited 7:12AM
    Wrong $this.

    Change to:

    $CI =& get_instance(); $CI->load->module_library('blog','fuel_blog'); $posts = $CI->fuel_blog->get_recent_posts();
  • edited 7:12AM
    I think there is something wrong. I get not only the recent posts but a large array with a lot of information.
  • edited 7:12AM
    Are you print_obj() or print_r() on the returned posts?

    You will get a load of info back as those records (IIRC) are tied to record class objects. It's expected.
  • edited 7:12AM
    Thanks for all your help. It worked.
Sign In or Register to comment.