Login
Oyunlar  

Changing recent topics to recent posts?

Changing recent topics to recent posts?

Postby Ghostryder on Tue Jun 12, 2007 4:30 pm

I am attempting to change the way in which recent.php displays recent posts.
i would rather if the display was ordered by recent post/reply rather than when the post was created.
can any1 assist with this, thanks?

Code: Select all
   <td class="row1" width="33%" valign="top">
      <!-- BEGIN latest_topics -->
         <a href="{latest_topics.U_VIEW_TOPIC}" title="{latest_topics.FULL_TITLE}">{latest_topics.TITLE}</a><br />
      <!-- END latest_topics -->

i thought changing all the instances of latest_topics to newposts might work, but it didnt
Ghostryder
 
Posts: 21
Joined: Thu May 24, 2007 12:19 am

Re: Changing recent topics to recent posts?

Postby StaticFX on Tue Jun 12, 2007 6:06 pm

you will actually need to go into the recent.php file (root\bb3portal\block\recent.php)

NOTE: THESE ARE COMPLETELY UNTESTED!!!!!!! But it should get you moving in the right direction
If You are not skilled at PHP & MySQL I would NOT attempt this.. the code below will get you close..
you may have to tweak the sql some... and other parts as well

look for this:
Code: Select all
//
// Recent topic (only show normal topic)
//
$sql = 'SELECT topic_title, forum_id, topic_id
   FROM ' . TOPICS_TABLE . '
   WHERE topic_status <> 2
      AND topic_approved = 1
      AND topic_type = 0
      ' . $sql_where . '
   ORDER BY topic_time DESC';

this is kinda off the top of my head... not sure of the acuracy.....
change the above code to something like this.. the query works, but again, i stress this... I am not
sure of how accurate this is...
Code: Select all
$sql = 'SELECT phpbb_posts.post_subject, phpbb_posts.post_text,phpbb_posts.forum_id,
phpbb_posts.topic_id, phpbb_posts.post_id, phpbb_posts.post_time, phpbb_posts.poster_id
FROM ' . POSTS_TABLE . ' LEFT JOIN phpbb_topics ON phpbb_posts.topic_id = phpbb_topics.topic_id
WHERE phpbb_topics.topic_status <> 2
AND phpbb_topics.topic_approved = 1
AND phpbb_topics.topic_type = 0
' . $sql_where . '
ORDER BY topic_time DESC'

now, just below that is where the variables are set (which are passed into the html file)
find this code....
Code: Select all
$template->assign_block_vars('latest_topics', array(
         'TITLE'          => character_limit($row['topic_title'], $CFG['recent_title_limit']),
         'FULL_TITLE'   => censor_text($row['topic_title']),
         'U_VIEW_TOPIC'   => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id'])
         )

and change it to something like this:
Code: Select all
$template->assign_block_vars('latest_topics', array(
      'SUBJECT'          => character_limit($row['phpbb_posts.post_subject'], $CFG['recent_title_limit']),
      'FULL_SUBJECT'   => censor_text($row['phpbb_posts.post_subject']),
      'POST_TEXT' => character_limit($row['phpbb_posts.post_text']),
      'POSTER' => $row['phpbb_posts.poster_id'], /* not sure offhand how to get username from id */
      'U_VIEW_NEW'   => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['phpbb_posts.forum_id'] . '&amp;t=' . $row['phpbb_posts.topic_id'] . '&amp;view=unread#unread'),
      'POST_TIME' => $user->format_date($row['phpbb_posts.post_time'])
      )


now in the recent.html file, change the variables to what you want to show.. make sure to use CAPITAL letters

Good luck!!!
hope this helps - again.. this will be trial and error
Image
StaticFX
 
Posts: 75
Joined: Thu May 10, 2007 5:52 pm

Re: Changing recent topics to recent posts?

Postby Ghostryder on Tue Jun 12, 2007 7:09 pm

thanks alot for the suggestion, its much more complicated than i first thought it might be.
I'll have a play around after some food.
:)
Ghostryder
 
Posts: 21
Joined: Thu May 24, 2007 12:19 am

Re: Changing recent topics to recent posts?

Postby spollin on Wed Jun 13, 2007 10:11 am

aha! this was just what i was looking for! will give it a go later this evening :) thanks :)
spollin
 
Posts: 20
Joined: Sat Jun 02, 2007 5:55 pm

Re: Changing recent topics to recent posts?

Postby StaticFX on Wed Jun 13, 2007 2:24 pm

:) guess what! I found my code from the previous version.. for B5

this is to change to recent posts instead of recent topics...
(plus it will give you more information to show, like # of views & posts & poster name etc...)

Open root/bb3portal/blocks/recent.php

find:
Code: Select all
$sql_where .= ' AND forum_id != ' . trim($id);


Add AFTER:
Code: Select all
$recent_where .= ' AND phpbb_topics.forum_id != ' . trim($id);

(note: this is needed because of the joins... there may be a better way.. but hey, this works! lol)


Find:
Code: Select all
//
// Recent topic (only show normal topic)
//
$sql = 'SELECT topic_title, forum_id, topic_id
   FROM ' . TOPICS_TABLE . '
   WHERE topic_status <> 2
      AND topic_approved = 1
      AND topic_type = 0
      ' . $sql_where . '
   ORDER BY topic_time DESC';


REPLACE WITH:
Code: Select all
//
// Recent Posts(only show normal posts)
//
$sql = "SELECT topic_title, phpbb_topics.forum_id, topic_id, topic_first_poster_name, topic_last_poster_name, topic_last_post_time,
   forum_name, topic_views, topic_replies, REPLACE(icons_url,'misc/','misc/r') as icon_url
   FROM " . TOPICS_TABLE . " LEFT JOIN phpbb_forums ON phpbb_topics.forum_id = phpbb_forums.forum_id
   LEFT JOIN phpbb_icons ON phpbb_topics.icon_id = phpbb_icons.icons_id
   WHERE topic_status <> 2
      AND topic_approved = 1
      " . $recent_where . "
   ORDER BY topic_last_post_time DESC";


Find After Above code: (its the last assign_block_vars)
Code: Select all
$template->assign_block_vars('latest_topics', array(
         'TITLE'          => character_limit($row['topic_title'], $CFG['recent_title_limit']),
         'FULL_TITLE'   => censor_text($row['topic_title']),
         'U_VIEW_TOPIC'   => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id'])
         )


REPLACE WITH:
Code: Select all
$template->assign_block_vars('latest_topics', array(
         'TITLE'          => character_limit($row['topic_title'], $CFG['recent_title_limit']),
         'FULL_TITLE'   => censor_text($row['topic_title']),
         'U_VIEW_TOPIC'   => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id']),
         'TOPIC_STARTER' => $row['topic_first_poster_name'],
         'TOPIC_LASTPOSTBY' => $row['topic_last_poster_name'],
         'TOPIC_LASTPOSTTIME' => $user->format_date($row['topic_last_post_time']),
         'FORUM_NAME' => $row['forum_name'],
         'T_VIEWS' => $row['topic_views'],
         'T_REPLIES' => $row['topic_replies'],
         'T_ICON' => isset($row['icon_url']) ? '<img src="http://staticfx.com/forums/images/icons/' . $row['icon_url'] . '" align="absmiddle" />' : '',
         'F_ID' => $row['forum_id']
         )


Now open root/style/{STYLENAME}/templates/bb3portal/blocks/recent.html

FIND:
Code: Select all
<!-- BEGIN latest_topics -->
                  <a href="{latest_topics.U_VIEW_TOPIC}" title="{latest_topics.FULL_TITLE}">{latest_topics.TITLE}</a><br />
               <!-- END latest_topics -->


and change to whatever you want... use each of the variable listed to create your display
Mine looks like this now (actually with a ton more changes to it , like expand on click etc...)
but it should at least show you how to use the different variables....
Code: Select all
<!-- BEGIN latest_topics -->
                              <tr style="background-color: rgb(58,68,79);">
                                 <td class="row1" valign="top">
                                       <a href="{latest_topics.U_VIEW_TOPIC}&view=unread#unread" title="{latest_topics.FULL_TITLE}">{latest_topics.TITLE}</a> {latest_topics.T_ICON}
                                       <br />
                                 </td>
                                 <td class="row1" valign="top">
                                       {latest_topics.T_VIEWS}
                                 </td>
                                 <td class="row1" valign="top">
                                       {latest_topics.T_REPLIES}
                                 </td>
                                 <td class="row1" valign="top">
                                       <a href="http://staticfx.com/forums/viewforum.php?f={latest_topics.F_ID}">{latest_topics.FORUM_NAME}</a>
                                 </td>
                                 <td class="row1" valign="top">
                                       {latest_topics.TOPIC_LASTPOSTBY}
                                 </td>
                                 <td class="row1" valign="top" align="center">
                                       {latest_topics.TOPIC_LASTPOSTTIME}
                                 </td>
                              </tr>
                              <!-- END latest_topics -->


to view a working sample:
http://forums.staticfx.com/

click on the Recent Topic link

ENJOY!
Image
StaticFX
 
Posts: 75
Joined: Thu May 10, 2007 5:52 pm

Re: Changing recent topics to recent posts?

Postby Ghostryder on Wed Jun 13, 2007 3:51 pm

that's great, I really appreciate it :D
The next task was to improve the info displayed there, so I'm doubly chuffed you included it anyway.
I'm off to edit the files now,
thanks again :)
Ghostryder
 
Posts: 21
Joined: Thu May 24, 2007 12:19 am

Re: Changing recent topics to recent posts?

Postby StaticFX on Wed Jun 13, 2007 4:11 pm

Glad to help!!
Image
StaticFX
 
Posts: 75
Joined: Thu May 10, 2007 5:52 pm

Re: Changing recent topics to recent posts?

Postby superhero on Fri Jun 15, 2007 5:14 am

I've done everything in that post except I have changed the way it looks a bit... but when I go to the portal page it still shows up as it used to. It does show the recent posts instead of topics, just it doesn't show any of the extra info... any idea what could be the problem?

I'm not the most experienced with php but this is the code I have used?

<!-- BEGIN latest_topics -->
a href="{latest_topics.U_VIEW_TOPIC}&view=unread#unread" title="{latest_topics.FULL_TITLE}">{latest_topics.TITLE}{latest_topics.TOPIC_LASTPOSTTIME} by {latest_topics.TOPIC_LASTPOSTBY}</a><br />
{latest_topics.TOPIC_LASTPOSTTIME} by {latest_topics.TOPIC_LASTPOSTBY}<br />
<!-- END latest_topics -->


effectively all I want is it to show

Post Title
14/6/07 by username


ideally I'd also like to show the time that the post was made, not just the date.
superhero
 
Posts: 4
Joined: Thu Jun 07, 2007 3:44 am

Re: Changing recent topics to recent posts?

Postby superhero on Fri Jun 15, 2007 6:28 am

OK, got that sorted out... I just discovered the inbuilt caching in phpbb 3!

What I need to figure out now though is how to make the username link to their profile...
superhero
 
Posts: 4
Joined: Thu Jun 07, 2007 3:44 am

Re: Changing recent topics to recent posts?

Postby StaticFX on Fri Jun 15, 2007 3:53 pm

Just crack open the top poster or newest member block.. take a look at the code used. I think most of the information is already being pulled in the query. If you get stuck let me know, i could probably do it.
Image
StaticFX
 
Posts: 75
Joined: Thu May 10, 2007 5:52 pm

Next

Return to [1.0.x] Support & Help



Who is online

Users browsing this forum: No registered users