Firefox PHP

Last X topics (and no posts)

Posted by Clément 
Re: Last X topics (and no posts)
August 23, 2007 05:43PM
Quote
Sergej
Panu, do you get a Session ID as well behind the normal Phorum links?

Nope, it would be easy to add to line 95 of the current version though.

---
-=[ Panu ]=-
Re: Last X topics (and no posts)
December 06, 2007 04:00AM
I've made this a templated page on my website, but also included the forum_id from the mySQL query in the php because I wanted each thread to list the forum name. I ended up getting the names by doing this in the php:
$msg['datestamp'] = date("F j, Y g:iA", $row1['datestamp']);
$msg['author'] = truncate_string($row1['author'], 25, 1);
$msg['message_id'] = $newest;
if ($row['forum_id'] == "4") {$msg['forum_id'] = "Ask Toby";}
elseif ($row['forum_id'] == "8") {$msg['forum_id'] = "Baaz Attack!";}
elseif ($row['forum_id'] == "6") {$msg['forum_id'] = "Computers";}
elseif ($row['forum_id'] == "2") {$msg['forum_id'] = "General";}
elseif ($row['forum_id'] == "7") {$msg['forum_id'] = "Music";}
elseif ($row['forum_id'] == "5") {$msg['forum_id'] = "Parties";}
I was wondering though, how can I get the forum name from forum_id without actually putting the names of my forums in the php? Thanks in advance for any help.

Re: Last X topics (and no posts)
December 06, 2007 09:22AM
You can use the database layer function phorum_db_get_forums() for that. Code could look somewhat like this:

// At the start of the script, outside the loop to show the messages:
$forums = phorum_db_get_forums();

// Within the loop:
$msg['forum_name'] = $forums[$row['forum_id']]['name'];


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Last X topics (and no posts)
December 07, 2007 12:41AM
awesome. that works perfectly. thanks for your help!

Re: Last X topics (and no posts)
December 09, 2007 01:04AM
I was looking at list_threads.tpl and list.php in an attempt to put new flags on threads listed by this module.
I noticed that list.php sets up new flags with
if ($PHORUM["DATA"]["LOGGEDIN"]) { // reading newflags in
$PHORUM['user']['newinfo']=phorum_db_newflag_get_flags();
}
if (!isset($PHORUM['user']['newinfo'][$row['message_id']]) && $row['message_id'] > $PHORUM['user']['newinfo']['min_id']) {
$rows[$key]["new"]=$PHORUM["DATA"]["LANG"]["newflag"];
}
and then can be called in a template with something like:
{IF ROWS->new}&nbsp;<span class="PhorumNewFlag">{ROWS->new}</span>{/IF}

This module uses a different loop though. How can I add a new flag to these threads?

Re: Last X topics (and no posts)
December 09, 2007 02:31AM
Maybe you can take at my Phorum 5.2+ Recent Messages module. That one adds newflags to the recent messages interface as well. I'm not sure if things are 100% compatible (at least the module isn't, so don't run it on Phorum 5.1), but the code might give you a hint on how to handle the newflags.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Last X topics (and no posts)
December 13, 2007 10:03PM
Thanks again. I think I have it working, but I've barely tested it. I have a feeling like I might have looked over something though. Below is Panu's code with a few things added. Let me know if you notice anything that doesn't look right:
	// more than 1 message in thread?
	if($newest > $row['message_id']){

		$query = "select * from ".$table." where message_id = ".$newest;
		$result1 = mysql_query($query);
		while($row1 = mysql_fetch_assoc($result1)){

			if ($PHORUM[mods][bbcode] == 1){
				$msgbody = preg_replace( "|</*[a-z][^>]*>|i", "", $row1['body']);
				$msg['body'] =  truncate_string(str_replace("#", "//", str_replace("/", "/", str_replace("//", "#", preg_replace( "|[/*[a-z][^\]]*\]|i", "", $msgbody)))), $preview_length, 1);

			}

			$msg['datestamp'] = date("F j, Y g:iA", $row1['datestamp']);
			$msg['author'] = truncate_string($row1['author'], 25, 1);
			$msg['message_id'] = $newest;
			$msg['forum_id'] = $row['forum_id'];
			$msg['forum_name'] = $forums[$row['forum_id']]['name'];
			// now trying to get newflags
			$msg['newflag'] = "";
			if ($PHORUM["DATA"]["LOGGEDIN"]) { // reading newflags in
    			$PHORUM['user']['newinfo']=phorum_db_newflag_get_flags($msg['forum_id']);
			}
            if (($PHORUM["DATA"]["LOGGEDIN"]) && (!isset($PHORUM['user']['newinfo'][$row['message_id']]) && $row['message_id'] > $PHORUM['user']['newinfo']['min_id'])) {
            	$msg['newflag']='(<font color="#FF6600"><small><b>new</b></small></font>)';
            }
	   }
	} else {

			if ($PHORUM[mods][bbcode] == 1){

				$msgbody = preg_replace( "|</*[a-z][^>]*>|i", "", $row['body']);
				$msg['body'] =  truncate_string(str_replace("#", "//", str_replace("/", "/", str_replace("//", "#", preg_replace( "|[/*[a-z][^\]]*\]|i", "", $msgbody)))), $preview_length, 1);

			}

			$msg['datestamp'] = date($date_format, $row['datestamp']);
			$msg['author'] = truncate_string($row['author'], 25, 1);
			$msg['message_id'] = $row['message_id'];
			$msg['forum_id'] = $row['forum_id'];
			$msg['forum_name'] = $forums[$row['forum_id']]['name'];
			// now trying to get newflags
			$msg['newflag'] = "";
			if ($PHORUM["DATA"]["LOGGEDIN"]) { // reading newflags in
    			$PHORUM['user']['newinfo']=phorum_db_newflag_get_flags($msg['forum_id']);
			}
            if (($PHORUM["DATA"]["LOGGEDIN"]) && (!isset($PHORUM['user']['newinfo'][$row['message_id']]) && $row['message_id'] > $PHORUM['user']['newinfo']['min_id'])) 			{
            	$msg['newflag']='(<font color="#FF6600"><small><b>new</b></small></font>)';
            }
	}

EDIT: It doesn't seem like it works perfectly all the time. Sometimes there are new posts that don't get the new flag??

EDIT2: nevermind. I fixed it. Just had to change $row['message_id'] to $msg['message_id'] in 2 places.





Edited 2 time(s). Last edit at 12/13/2007 11:48PM by Davey.
Sorry, only registered users may post in this forum.

Click here to login