-

How to display blog entries on a different phpBB3 page

Forum rules
Before posting or asking for help, read this topic:
viewtopic.php?f=41&t=674

How to display blog entries on a different phpBB3 page

Postby EXreaction » Fri Dec 12, 2008 12:48 pm

Setting up a display of the blog entries on a phpBB3 page is quite easy to do.

In this I will write up a quick tutorial on how to add a list of the 5 most recent blog entries on the index page below the forum list.

Open: index.php

Find:
Code: Select all
// Output page


Before, Add:
Code: Select all
// Output Blog Entries
$blog_limit = 5;

$user->add_lang(array('mods/blog/common', 'mods/blog/view'));
include($phpbb_root_path . 'blog/functions.' . $phpEx);
$blog_data = new blog_data();

$recent_blog_ids = $blog_data->get_blog_data('recent', 0, array('limit' => $blog_limit));
$blog_data->get_user_data(false, true);
update_edit_delete();
if ($recent_blog_ids !== false)
{
   foreach ($recent_blog_ids as $id)
   {
      $template->assign_block_vars('recent_blogs', array_merge($blog_data->handle_user_data(blog_data::$blog[$id]['user_id']), $blog_data->handle_blog_data($id, $config['user_blog_text_limit'])));
   }
}


Open: styles/prosilver/template/index_body.html

Find:
Code: Select all
<!-- INCLUDE forumlist_body.html -->


After, add:
Code: Select all
<!-- IF .recent_blogs -->
<div class="post bg3" style="text-align: center;">
   <span class="corners-top"><span></span></span>
      <strong>{L_RECENT_BLOGS}</strong>
   <span class="corners-bottom"><span></span></span>
</div>
<!-- BEGIN recent_blogs -->
   <div class="post bg1<!-- IF recent_blogs.S_REPORTED or recent_blogs.S_UNAPPROVED --> reported<!-- ENDIF --><!-- IF recent_blogs.S_DELETED --> deleted<!-- ENDIF -->" <!-- IF recent_blogs.POST_COLOR and not recent_blogs.S_REPORTED and not recent_blogs.S_UNAPPROVED and not recent_blogs.S_DELETED -->style="background-color: {recent_blogs.POST_COLOR}"<!-- ENDIF -->>
      <div class="inner"><span class="corners-top"><span></span></span>

      <div class="postbody" style="width: 100%;">
         <!-- IF recent_blogs.S_UNAPPROVED or recent_blogs.S_REPORTED -->
            <p class="rules">
               <!-- IF recent_blogs.S_UNAPPROVED -->{UNAPPROVED_IMG} <a href="{recent_blogs.U_APPROVE}"><strong>{L_UNAPPROVED}</strong></a><!-- ENDIF -->
               <!-- IF recent_blogs.S_REPORTED -->{REPORTED_IMG} <a href="{recent_blogs.U_REPORT}"><strong>{L_REPORTED_SHORT}</strong></a><!-- ENDIF -->
            </p>
         <!-- ENDIF -->

         <dl>
            <dt>
               <strong><!-- IF recent_blogs.S_HAS_POLL --><img src="{T_THEME_PATH}/images/blog/icon_poll.gif" style="float: right;" alt="" /> <!-- ENDIF --><a href="{recent_blogs.U_VIEW}">{recent_blogs.TITLE}</a></strong> {L_POST_BY_AUTHOR} <strong>{recent_blogs.USER_FULL}</strong>  {L_POSTED_ON_DATE} {recent_blogs.DATE} <br />
               <div class="content" style="width: 95%; padding: 4px;">{recent_blogs.MESSAGE}</div>

               <!-- IF recent_blogs.S_HAS_ATTACHMENTS -->
                  <dl class="attachbox">
                     <dt>{L_ATTACHMENTS}</dt>
                  </dl>
               <!-- ENDIF -->

               <br clear="all" />
               <div>
                  <span class="num_replies">{recent_blogs.REPLIES}</span>
                  {recent_blogs.VIEWS}
               </div>
            </dt>
         </dl>
      </div>
      <span class="corners-bottom"><span></span></span>
   </div>
</div>
<!-- END recent_blogs -->
<!-- ENDIF -->


The main things you may like to change are the number of items displayed, and that can be changed by altering the $blog_limit in the code added to index.php, and how the blog entries are displayed. If you want them displayed in a different way you'll have to figure that out for yourself, but you can put the template code pretty much anywhere on the index_body you would like.
Grateful for the mods I've built? Then donate!
User avatar
EXreaction
Site Owner
Site Owner
 
Posts: 4988
Joined: Wed Jun 28, 2006 5:08 pm
Blog: View Blog (53)

Re: How to display blog entries on a different phpBB3 page

Postby bloggo » Mon Dec 29, 2008 1:40 pm

Hello,
editing index.php I see this error when I log in as user and not as an administrator:

[phpBB Debug] PHP Notice: in file /blog/includes/functions_permissions.php on line 71: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object
[phpBB Debug] PHP Notice: in file /blog/includes/functions_permissions.php on line 71: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object
[phpBB Debug] PHP Notice: in file /blog/includes/functions_permissions.php on line 71: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object


Thanks for your help

Bloggo
bloggo
Donor
Donor
 
Posts: 14
Joined: Mon Dec 29, 2008 1:35 pm
Blog: View Blog (0)

Re: How to display blog entries on a different phpBB3 page

Postby EXreaction » Mon Dec 29, 2008 5:23 pm

I see, that is a bug. I'll fix that for the next version of the User Blog Mod, but until then,

Open
blog/includes/functions_permissions.php

Find:
Code: Select all
if (!array_key_exists($user_id, $zebra_list))


Replace with:
Code: Select all
if (!is_array($zebra_list) || !array_key_exists($user_id, $zebra_list))
Grateful for the mods I've built? Then donate!
User avatar
EXreaction
Site Owner
Site Owner
 
Posts: 4988
Joined: Wed Jun 28, 2006 5:08 pm
Blog: View Blog (53)

Re: How to display blog entries on a different phpBB3 page

Postby bloggo » Thu Jan 01, 2009 2:28 pm

Thank you :)
bloggo
Donor
Donor
 
Posts: 14
Joined: Mon Dec 29, 2008 1:35 pm
Blog: View Blog (0)

Re: How to display blog entries on a different phpBB3 page

Postby Acorn » Fri Jan 16, 2009 3:17 am

Brilliant! :lol: I can't tell you how many times I've come here hoping I'll be able to figure out how to do something, only to find out that you've already done it!

I'd like to make the recent entry list a bit more compact by removing the [ Continued ] and the blank lines above and below it from each entry. Could you tell me where and how to do this please?

Thank you. :D
User avatar
Acorn
Donor
Donor
 
Posts: 31
Joined: Fri Oct 10, 2008 8:04 am
Blog: View Blog (0)

Re: How to display blog entries on a different phpBB3 page

Postby EXreaction » Fri Jan 16, 2009 12:18 pm

Changing that just for this recent list would be rather difficult.

You'd have to take the $blog_data->handle_blog_data($id, $config['user_blog_text_limit']) code and set it into a separate array, then edit the text, then use that array in place of that code you had to copy above ($blog_data->handle_blog_data($id, $config['user_blog_text_limit'])).

Basically:
Code: Select all
   foreach ($recent_blog_ids as $id)
   {
        $blog = $blog_data->handle_blog_data($id, $config['user_blog_text_limit']);
        // edit the blog text here.
        $template->assign_block_vars('recent_blogs', array_merge($blog_data->handle_user_data(blog_data::$blog[$id]['user_id']), $blog));
   }
Grateful for the mods I've built? Then donate!
User avatar
EXreaction
Site Owner
Site Owner
 
Posts: 4988
Joined: Wed Jun 28, 2006 5:08 pm
Blog: View Blog (53)

Re: How to display blog entries on a different phpBB3 page

Postby Acorn » Fri Jan 16, 2009 12:34 pm

Oooooh. I think that's a bit beyond me. I'll have to decide whether to keep it as it is or make it a list of blog titles without the text.

Thanks for your help. :)
User avatar
Acorn
Donor
Donor
 
Posts: 31
Joined: Fri Oct 10, 2008 8:04 am
Blog: View Blog (0)

Re: How to display blog entries on a different phpBB3 page

Postby dupko » Tue Aug 07, 2012 2:46 am

EXreaction wrote:Changing that just for this recent list would be rather difficult.

You'd have to take the $blog_data->handle_blog_data($id, $config['user_blog_text_limit']) code and set it into a separate array, then edit the text, then use that array in place of that code you had to copy above ($blog_data->handle_blog_data($id, $config['user_blog_text_limit'])).

Basically:
Code: Select all
   foreach ($recent_blog_ids as $id)
   {
        $blog = $blog_data->handle_blog_data($id, $config['user_blog_text_limit']);
        // edit the blog text here.
        $template->assign_block_vars('recent_blogs', array_merge($blog_data->handle_user_data(blog_data::$blog[$id]['user_id']), $blog));
   }


Thats rly difficult, :o
dupko
Member
Member
 
Posts: 1
Joined: Tue Aug 07, 2012 2:45 am
Blog: View Blog (0)


Return to User Blog Mod



Who is online

Users browsing this forum: jersey5277 and 3 guests

cron