Fuel CMS Blog Module

edited May 2013 in Modules
Hi,

I am new to Fuel CMS. I am trying to explore the blog module and how to modify it. Basically, I want to create a two column page in the form of a blog where the left column (sidebar) will display the archives and also the posts (in a preview format) in a vertical layout. On clicking on one of these previews posts we will get a detailed post on the right column. It will not change the whole page in the blog. How can I achieve this?

Essentially, an affect like this: http://3.bp.blogspot.com/-lNkPQU2kVz0/USeI51ork9I/AAAAAAAAK-4/bc1LEy2nhRc/s640/bonepress-free-wordpress-theme.PNG

Thanks

Comments

  • edited 8:39PM
    The blog module is made up of several "simple" modules with the most important one being the blog_posts module. This module uses the blog_posts_model to house the information for the blog posts. Categorizing the posts is done with the blog_categories module that uses the blog_posts_categories_model. The fuel/modules/blog/controllers/blog.php controller grabs the posts and sends them to the view files in the the fuel/modules/blog/views/themes/default/ folder. I start by looking at those files to see how the post data is presented in the views.
  • edited 8:39PM
    Thanks, I also wanted to know where/if there's a css for the div elements used in the blog files? I could not find a separate css. (i.e for main_inner div id etc.)
  • edited 8:39PM
    In short, I just needed help with this:

    I want to open individual blog post within the same page (where the list of posts are shown) within a div element rather than having it open in a new page. Is there a way to do that?

    Thanks.
  • edited 8:39PM
    The css being pulled in depends on what is in the header of your page. The blog has a header that it pulls in which has a blog.css file which would need to change based on your designs.

    With regards to loading in the blog post on the same page, are you wanting to AJAX in the content of that blog post to that page? If so, you can create a controller that allows you to pass it a blog post ID and returns the data for that post which you can inject into that page... very similar to what the blog.php controller does in the "post" method but without the header and footer content attached to it (since it's AJAXed in).
  • edited 8:39PM
    I do want to AJAX it in. I was doing this before:

    In posts.php under views,
    div id="left"
    <?php echo $this->fuel_blog->sidemenu(array('archives'))?> //Left div
    /div

    div id="detail" //Right div to show detail
    /div

    Then in posts.php under _blocks, I do this:

    a href="javascript:ajaxpage('<?=$post->url?>', 'detail');"><?=$post->title?>

    ajaxpage is a javascript function that will return the post (i think) and put the returned content in the "detail" div.

    http://pastie.org/private/03xu5qpiwsmqotwyq2xqq

    Does this sound right? The problem i am having is that header and footer seem to be messing up my css.
  • edited 8:39PM
    You can use jquery to target a specific node in that page if you can't get rid of the header and footer. See the jQuery "load" method. You could use the is_ajax() function in your header and footer to determine whether to render them based on if it's an AJAX request.
    http://api.jquery.com/load/
  • edited 8:39PM
    Thanks. I managed to do this without utilizing AJAX.Hopefully it works.

    I have another question to ask:

    So, I have the two div layout as I described before in the blog module that works ok if I don't use any images. Now, when I create the blog post with some image added to the post content area, I want my image to appear only in the right div. Currently, it appears in both left and right div's which messes up my css. Any thoughts?

    Thanks!
  • edited 8:39PM
    I'm not quite sure I understand. Does the archives sidemenu block use images in it?
  • edited 8:39PM
    no but I have modified the blog like I said before so the left sidemenu actually displays archives and post too. So, now when I write a post to a blog and use images in the content, it appears both in the sidemenu and also the right div.
  • edited 8:39PM
    I see... can you just use strip_tags on it?

    If you are using the 1.0 beta, there is a "_stripped" formatter you can use:
    <?php echo $post->content_stripped?>
  • edited 8:39PM
    Thanks for that. I actually managed to do it using $post->excerpt_formatted. Is that the same thing?

    Also, one more question, I cannot get to cover the whole background of the left sidebar with color. The color only displays till the text content. Any thoughts about it?
  • edited 8:39PM
    That sounds like you may need to apply the CSS background color on a parent element but tough to say.
  • edited 8:39PM
    Thanks the css issue was resolved.
  • edited 8:39PM
    Hi,

    I tried to use <?php echo $post->content_stripped?> to remove images from the left sidebar but that removes the content also. I can just see the title. Can I do something else?

    Thanks
  • edited 8:39PM
    content_stripped simply runs the strip_tags function on the $post->content values. Does strip_tags($post->_content) work?
  • edited 8:39PM
    Yes, I had to do strip_tags($post->content_formatted) that removes the tags. I don't know why just doing $post->content_stripped did not work. Maybe because I do not want

    tags to be removed?

  • edited 8:39PM
    This is using FUEL 1.0 correct?
  • edited 8:39PM
    Oh, hmm no actually its version 0.9.3.
  • edited 8:39PM
    OK... that would explain the content_formatted not working. That's a 1.0 feature.
  • edited 8:39PM
    Ok. So, I have got the left and right divs to work properly. Just having two more issues:

    1. There is a strange space between the post title and post content on the left side div element even though I have kept the margin as 0px.

    2. Another feature I would like to add is a "newer entries" and "older entries" link to the right div so I can browse through them without clicking on links separately on the left. Also, if I click on archives for a month on the left side bar, the "older or newer entries" section would only display posts from that month.
  • edited 8:39PM
    There is a $this->fuel_blog->get_next_post() and $this->fuel_blog->get_prev_post() that you can use to get the next and previous post. However, if you are wanting to get a specific month or even year, you can browse the posts as such:
    /blog/2013/05/ (month)
    /blog/2013/ (year)

    If you are wanting the archives, that will present a grouping of posts by month and year on a page using the $this->fuel_blog->get_post_archives() method.

    The fuel/modules/blog/libraries/Fuel_blog class has several methods on it that may help you to grab the proper posts.
  • edited 8:39PM
    The $this->fuel_blog->get_next_post() will work but I have to create links like "Older Posts" under each detailed post on the right div. If we click on that link the right div is filled with the one previous post. I see how get_next and get_prev can play a part here but how will I put those functions under a "a" tag i.e "a href="<?=$this->fuel_blog->get_prev_post()?>"Older Posts </a" ?
  • edited 8:39PM
    Those functions return blog post objects in which you can use there url property like so:
    $next_post = $this->fuel_blog->get_next_post(); <a href="<?=$next_post->url?>">NEXT</a>
  • edited 8:39PM
    The url property does not work. It gives me an error saying

    A PHP Error was encountered
    Severity: Notice

    Message: Trying to get property of non-object

    I supply the $posts as argument to get_next_post()
  • edited May 2013
    I got this to work finally. Had to do this: a href="<?=$this->fuel_blog->get_next_post($post)->url?>">Newer Entries/a

    I actually have two pages where $post as argument works for one page but doesn't work for the first or the last post. It works fine for the middle posts.
Sign In or Register to comment.