Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Blocks
Author Message
stclem
Regular
Regular



Joined: Oct 18, 2008
Posts: 52

PostPosted: Tue Dec 09, 2008 11:50 am Reply with quote

im using original forum block, but want to change it.

1. Can someone help me to add the date for last post in a topic behind the topic tittle?

2. Is it any easy way to add number of post in a topic behind the topic tittle?

Then it be like this.

- Topic tittle (2) date

thanks


Code:
if ( !defined('BLOCK_FILE') ) {

   Header('Location: ../index.php');
   die();
}

global $prefix, $db, $sitename;

$sql = 'SELECT t.forum_id, topic_id, topic_title, auth_view, auth_read FROM '.$prefix.'_bbtopics AS t, '.$prefix.'_bbforums AS f WHERE f.forum_id=t.forum_id ORDER BY topic_time DESC LIMIT 10';
$result = $db->sql_query($sql);
$content = '<br />';
while (list($forum_id, $topic_id, $topic_title, $auth_view, $auth_read) = $db->sql_fetchrow($result)) {
   if (($auth_view < 2) OR ($auth_read < 2)) {
      $content .= '<img src="images/arrow.gif" border="0" alt="" title="" width="9" height="9" /> <a href="forums.html?amp;file=viewtopic&amp;t='.$topic_id.'">'.$topic_title.'</a><br />';
   }
}

$content .= '<br /><center><a href="forums.html"><b>'.$sitename.' Forums</b></a><br /><br /></center>';
?>
 
View user's profile Send private message
kguske
Site Admin



Joined: Jun 04, 2004
Posts: 6432

PostPosted: Wed Dec 10, 2008 12:40 pm Reply with quote

That's an interesting idea. I will look into that for the feeds while addressing another issue, and that should help me identify what you're looking for.

_________________
I search, therefore I exist...
nukeSEO - nukeFEED - nukePIE - nukeSPAM - nukeWYSIWYG
 
View user's profile Send private message
Palbin
Site Admin



Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania

PostPosted: Wed Dec 10, 2008 3:01 pm Reply with quote

stclem, its easy. I will look at it when I get home tonight.

_________________
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan. 
View user's profile Send private message
stclem







PostPosted: Thu Dec 11, 2008 3:03 am Reply with quote

yeah, easy, right Very Happy

know its not a hard work, have tryed to take code from center forum block, but dont get it to work.

So for people who know this it would be not a to dificult thing Thanks.
 
stclem







PostPosted: Sun Dec 14, 2008 5:17 am Reply with quote

Palbin wrote:
stclem, its easy. I will look at it when I get home tonight.


did you get a look at it?
 
Palbin







PostPosted: Sun Dec 14, 2008 10:23 am Reply with quote

Been busy with the holidays coming up. I should be able to take a gander at it today.
 
Palbin







PostPosted: Mon Dec 15, 2008 6:23 am Reply with quote

OK this took a little longer and was a little more complex than I thought. I have posted the code below, but I would go to this link to get a copy of the code because the rewrite rules on this site alter the links in the code. You may want to change how everything is displayed, but this should get you well on your way.
[ Only registered users can see links on this board! Get registered or login! ]

Code:


<?php
if ( !defined('BLOCK_FILE') ) {
   Header('Location: ../index.php');
   die();
}

global $aid, $user, $cookie, $prefix, $user_prefix, $db, $sitename, $userinfo;

// Calculate posting time offset for user defined timezones
$serverTimeZone = date("Z")/3600;

if ($serverTimeZone >= 0) $serverTimeZone = "+".$serverTimeZone;

if (is_user($user)) {
    cookiedecode($user);
    $uid = $cookie[0];
    $name = $cookie[1];
   
    $userinfo     = getusrinfo($user);
    $userTimeZone = $userinfo['user_timezone'];
    $userDateFormat = $userinfo['user_dateformat'];
}
else {
    $uid = 1;
    $name = "$anonymous";

   $sql  = "SELECT v1.config_value , v2.config_value  FROM ".$prefix."_bbconfig v1, ".$prefix."_bbconfig v2  WHERE v1.config_name='board_timezone' and v2.config_name='default_dateformat' ";
   $result = $db->sql_query($sql);
   list($userTimeZone, $userDateFormat) = $db->sql_fetchrow($result);
}

$userTimeZone = ($userTimeZone - $serverTimeZone)*3600;

if (!is_numeric($userTimeZone)) $userTimeZone = 0;


$sql = "SELECT p.poster_id, p.post_time, p.post_username, u.username, u.user_id, u.user_color_gc
    FROM ".$prefix."_bbposts p, ".$user_prefix."_users u
    WHERE p.post_id = '$topic_last_post_id'
    AND u.user_id = p.poster_id";

$result2 = $db->sql_query($sql);
list($poster_id, $post_time, $post_username, $username, $user_id, $user_color_gc) = $db->sql_fetchrow($result2);

if( $user_id == 1 && $post_username != '' ) {
    $username = $post_username;
}




$sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, t.topic_time, t.topic_replies, t.topic_last_post_id, f.forum_id, f.auth_view, f.auth_read FROM '.$prefix.'_bbtopics AS t, '.$prefix.'_bbforums AS f WHERE f.forum_id = t.forum_id ORDER BY t.topic_time DESC LIMIT 10';
$result = $db->sql_query($sql);
$content = '<br />';
while (list($tforum_id, $topic_id, $topic_title, $topic_time, $topic_replies, $topic_last_post_id, $forum_id, $auth_view, $auth_read) = $db->sql_fetchrow($result)) {
   if (($auth_view < 2) OR ($auth_read < 2)) {
        $sql2 = 'SELECT p.post_id, p.post_time FROM '.$prefix.'_bbposts AS p WHERE p.post_id =  '.$topic_last_post_id.'';
        $result2 = $db->sql_query($sql2);
        list($post_id, $post_time) = $db->sql_fetchrow($result2);
        $post_time = date($userDateFormat, ($post_time + $userTimeZone));
        $content .= '<img src="images/arrow.gif" border="0" alt="" title="" width="9" height="9" /> <a href="forums.html?amp;file=viewtopic&amp;t='.$topic_id.'">'.$topic_title.'</a>&nbsp;('.$topic_replies.')<i>&nbsp;&nbsp;'.$post_time.'</i><br />';
    }
}

$content .= '<br /><center><a href="forums.html"><b>'.$sitename.' Forums</b></a><br /><br /></center>';
?>
 
stclem







PostPosted: Mon Dec 15, 2008 8:29 am Reply with quote

The number behind was perfect. The date was not so good, it worked, but was to big if you understand.
It becomes like this

forum topic (1) Tue Dec 02, 2008 8:03 pm

Is it easy to get it like this

forum topic (1) ddmmyy tt:mm

if its a lot of work i really dont ned it, but if its easy please help.
PS: nead a 24 hour clock and not am/pm.

thanks.
 
Palbin







PostPosted: Mon Dec 15, 2008 9:21 am Reply with quote

It is setup to use the user defined date format from your account, but I can make it use what ever you want. I'll look at it tonight. We just need to play with this line:
Code:


$post_time = date($userDateFormat, ($post_time + $userTimeZone));
 
Palbin







PostPosted: Mon Dec 15, 2008 11:33 am Reply with quote

Try this:

Code:


$post_time = date('d-m-y H:i', ($post_time + $userTimeZone));


I haven't tested it, but give it a try and let me know.
 
stclem







PostPosted: Mon Dec 15, 2008 12:16 pm Reply with quote

perfect! Thanks a lot.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Blocks

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©