Last X topics (and no posts)
Posted by Clément
Re: Last X topics (and no posts) August 23, 2007 11:43AM |
Registered: 22 years ago Posts: 1,076 |
Re: Last X topics (and no posts) December 05, 2007 10:00PM |
Registered: 16 years ago Posts: 10 |
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 03:22AM |
Admin Registered: 19 years ago Posts: 8,532 |
You can use the database layer function phorum_db_get_forums() for that. Code could look somewhat like this:
Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
// 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 06, 2007 06:41PM |
Registered: 16 years ago Posts: 10 |
Re: Last X topics (and no posts) December 08, 2007 07:04PM |
Registered: 16 years ago Posts: 10 |
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
This module uses a different loop though. How can I add a new flag to these threads?
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} <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 08, 2007 08:31PM |
Admin Registered: 19 years ago Posts: 8,532 |
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
Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Last X topics (and no posts) December 13, 2007 04:03PM |
Registered: 16 years ago Posts: 10 |
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:
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 05:48PM by Davey.
// 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 05:48PM by Davey.
Sorry, only registered users may post in this forum.