Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: xxx - tammikuu 02, 2006, 07:24:17 AP

Otsikko: show with a picture when there are new post on a thread.
Kirjoitti: xxx - tammikuu 02, 2006, 07:24:17 AP
I have 1 speciale thread and a want to show with a icon (of something) that there is a new post on it elsewhere on my board.
The thread is hidden and the people entered it on a banner no.
Next the banner a want a icon that told when there are new postings on this thread.

I hope someone understand this.
Otsikko: Re: show with a picture when there are new post on a thread.
Kirjoitti: Dannii - tammikuu 02, 2006, 10:37:17 IP
I'm not sure if this will work, and I'm sure it could be optimised a lot but try this:
$result = db_query("
SELECT
b.ID_BOARD, b.name, b.description, b.numTopics, b.numPosts,
m.posterName, m.posterTime, m.subject, m.ID_MSG, m.ID_TOPIC,
IFNULL(mem.realName, m.posterName) AS realName, " . (!$user_info['is_guest'] ? "
(IFNULL(lb.logTime, 0) >= b.lastUpdated) AS isRead," : "1 AS isRead,") . "
IFNULL(mem.ID_MEMBER, 0) AS ID_MEMBER, IFNULL(mem2.ID_MEMBER, 0) AS ID_MODERATOR,
mem2.realName AS modRealName
FROM {$db_prefix}boards AS b
LEFT JOIN {$db_prefix}messages AS m ON (m.ID_MSG = b.ID_LAST_MSG)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
LEFT JOIN {$db_prefix}log_boards AS lb ON (lb.ID_BOARD = b.ID_BOARD AND lb.ID_MEMBER = $ID_MEMBER)" : '') . "
LEFT JOIN {$db_prefix}moderators AS mods ON (mods.ID_BOARD = b.ID_BOARD)
LEFT JOIN {$db_prefix}members AS mem2 ON (mem2.ID_MEMBER = mods.ID_MEMBER)
WHERE m.ID_TOPIC = YOURTOPICIDNUMBER
AND $user_info[query_see_board]", __FILE__, __LINE__);
while ($row_board = mysql_fetch_assoc($result))
{ $new = empty($row_board['isRead']) && $row_board['posterName'] != ''; }
mysql_free_result($result);
if $new echo 'IMAGE';
Change YOURTOPICIDNUMBER and IMAGE of course.
Otsikko: Re: show with a picture when there are new post on a thread.
Kirjoitti: xxx - tammikuu 03, 2006, 07:26:53 AP
I have this on my board:
Lainaaecho '

<div class="tborder"><table border="0" width="100%" cellspacing="1" cellpadding="4"> ';
echo '
<div class="tborder"><table border="0" width="100%" cellspacing="1" cellpadding="6">
<tr><td class="windowbg2" width="100%" align="center">
<a href="http://www.xxxforum.be/index.php?topic=2263.0"><img src="http://www.xxxforum.be/kroeg.jpg" border="0" alt="Kroeg"/></a></td>
</tr></div>';       
echo '
</table></div>';

When there is a new post on the topic=2263.0  the image (...../kroeg.jpg) have to change in another image.

How can i do this with your Query???????
Otsikko: Re: show with a picture when there are new post on a thread.
Kirjoitti: Dannii - tammikuu 03, 2006, 08:05:24 AP
      echo '

<div class="tborder"><table border="0" width="100%" cellspacing="1" cellpadding="4"> ';
echo '
<div class="tborder"><table border="0" width="100%" cellspacing="1" cellpadding="6">
<tr><td class="windowbg2" width="100%" align="center">
<a href="http://www.xxxforum.be/index.php?topic=2263.0">';
$result = db_query("
SELECT
b.ID_BOARD, b.name, b.description, b.numTopics, b.numPosts,
m.posterName, m.posterTime, m.subject, m.ID_MSG, m.ID_TOPIC,
IFNULL(mem.realName, m.posterName) AS realName, " . (!$user_info['is_guest'] ? "
(IFNULL(lb.logTime, 0) >= b.lastUpdated) AS isRead," : "1 AS isRead,") . "
IFNULL(mem.ID_MEMBER, 0) AS ID_MEMBER, IFNULL(mem2.ID_MEMBER, 0) AS ID_MODERATOR,
mem2.realName AS modRealName
FROM {$db_prefix}boards AS b
LEFT JOIN {$db_prefix}messages AS m ON (m.ID_MSG = b.ID_LAST_MSG)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
LEFT JOIN {$db_prefix}log_boards AS lb ON (lb.ID_BOARD = b.ID_BOARD AND lb.ID_MEMBER = $ID_MEMBER)" : '') . "
LEFT JOIN {$db_prefix}moderators AS mods ON (mods.ID_BOARD = b.ID_BOARD)
LEFT JOIN {$db_prefix}members AS mem2 ON (mem2.ID_MEMBER = mods.ID_MEMBER)
WHERE m.ID_TOPIC = YOURTOPICIDNUMBER
AND $user_info[query_see_board]", __FILE__, __LINE__);
while ($row_board = mysql_fetch_assoc($result))
{ $new = empty($row_board['isRead']) && $row_board['posterName'] != ''; }
mysql_free_result($result);
if $new { echo 'OTHERIMAGE'; }
else { '<img src="http://www.xxxforum.be/kroeg.jpg" border="0" alt="Kroeg"/>'; }
echo '</a></td>
</tr></div>';       
echo '
</table></div>';
Again, I'm not sure that will work.
Otsikko: Re: show with a picture when there are new post on a thread.
Kirjoitti: xxx - tammikuu 03, 2006, 08:19:02 AP
LainaaTemplate Parse Error!
There was a problem loading the /Themes/helios/BoardIndex.template.php template or language file. Please check the syntax and try again - remember, single quotes (') often have to be escaped with a slash (\). To see more specific error information from PHP, try accessing the file directly.

You may want to try to refresh this page or use the default theme.


I try this:
Lainaaecho '

<div class="tborder"><table border="0" width="100%" cellspacing="1" cellpadding="4"> ';
echo '
<div class="tborder"><table border="0" width="100%" cellspacing="1" cellpadding="6">
<tr><td class="windowbg2" width="100%" align="center">
<a href="http://www.xxxforum.be/index.php?topic=2263.0">';
$result = db_query("
SELECT
b.ID_BOARD, b.name, b.description, b.numTopics, b.numPosts,
m.posterName, m.posterTime, m.subject, m.ID_MSG, m.ID_TOPIC,
IFNULL(mem.realName, m.posterName) AS realName, " . (!$user_info['is_guest'] ? "
(IFNULL(lb.logTime, 0) >= b.lastUpdated) AS isRead," : "1 AS isRead,") . "
IFNULL(mem.ID_MEMBER, 0) AS ID_MEMBER, IFNULL(mem2.ID_MEMBER, 0) AS ID_MODERATOR,
mem2.realName AS modRealName
FROM {$db_prefix}boards AS b
LEFT JOIN {$db_prefix}messages AS m ON (m.ID_MSG = b.ID_LAST_MSG)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
LEFT JOIN {$db_prefix}log_boards AS lb ON (lb.ID_BOARD = b.ID_BOARD AND lb.ID_MEMBER = $ID_MEMBER)" : '') . "
LEFT JOIN {$db_prefix}moderators AS mods ON (mods.ID_BOARD = b.ID_BOARD)
LEFT JOIN {$db_prefix}members AS mem2 ON (mem2.ID_MEMBER = mods.ID_MEMBER)
WHERE m.ID_TOPIC = 2263.0
AND $user_info[query_see_board]", __FILE__, __LINE__);
while ($row_board = mysql_fetch_assoc($result))
{ $new = empty($row_board['isRead']) && $row_board['posterName'] != ''; }
mysql_free_result($result);
if $new { echo '<img src="http://www.xxxforum.be/kroeg1.jpg" border="0" alt="Kg"/>'; }
else { '<img src="http://www.xxxforum.be/kroeg.jpg" border="0" alt="Kroeg"/>'; }
echo '</a></td>
</tr></div>';
echo '
</table></div>';


Where can I fix this????
Otsikko: Re: show with a picture when there are new post on a thread.
Kirjoitti: Dannii - tammikuu 03, 2006, 08:33:56 AP
      echo '

<div class="tborder"><table border="0" width="100%" cellspacing="1" cellpadding="4"> ';
echo '
<div class="tborder"><table border="0" width="100%" cellspacing="1" cellpadding="6">
<tr><td class="windowbg2" width="100%" align="center">
<a href="http://www.xxxforum.be/index.php?topic=2263.0">';
$result = db_query("
SELECT
b.ID_BOARD, b.name, b.description, b.numTopics, b.numPosts,
m.posterName, m.posterTime, m.subject, m.ID_MSG, m.ID_TOPIC,
IFNULL(mem.realName, m.posterName) AS realName, " . (!$user_info['is_guest'] ? "
(IFNULL(lb.logTime, 0) >= b.lastUpdated) AS isRead," : "1 AS isRead,") . "
IFNULL(mem.ID_MEMBER, 0) AS ID_MEMBER, IFNULL(mem2.ID_MEMBER, 0) AS ID_MODERATOR,
mem2.realName AS modRealName
FROM {$db_prefix}boards AS b
LEFT JOIN {$db_prefix}messages AS m ON (m.ID_MSG = b.ID_LAST_MSG)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
LEFT JOIN {$db_prefix}log_boards AS lb ON (lb.ID_BOARD = b.ID_BOARD AND lb.ID_MEMBER = $ID_MEMBER)" : '') . "
LEFT JOIN {$db_prefix}moderators AS mods ON (mods.ID_BOARD = b.ID_BOARD)
LEFT JOIN {$db_prefix}members AS mem2 ON (mem2.ID_MEMBER = mods.ID_MEMBER)
WHERE m.ID_TOPIC = YOURTOPICIDNUMBER
AND $user_info[query_see_board]", __FILE__, __LINE__);
while ($row_board = mysql_fetch_assoc($result))
{ $new = empty($row_board['isRead']) && $row_board['posterName'] != ''; }
mysql_free_result($result);
if $new { echo '<img src="http://www.xxxforum.be/kroeg1.jpg" border="0" alt="Kg"/>'; }
else { echo '<img src="http://www.xxxforum.be/kroeg.jpg" border="0" alt="Kroeg"/>'; }
echo '</a></td>
</tr></div>';       
echo '
</table></div>';
Argh silly mistake, I left out an echo.
Otsikko: Re: show with a picture when there are new post on a thread.
Kirjoitti: xxx - tammikuu 03, 2006, 09:04:41 AP
Template Parse Error!

It seems to be more than just an echo :(

please can you fix it???
Otsikko: Re: show with a picture when there are new post on a thread.
Kirjoitti: xxx - tammikuu 04, 2006, 11:25:37 AP
Please, can anyone fix this ???
Otsikko: Re: show with a picture when there are new post on a thread.
Kirjoitti: xxx - tammikuu 07, 2006, 11:46:56 AP
This is new but it gives a database error.
Lainaa
echo '

<div class="tborder"><table border="0" width="100%" cellspacing="1" cellpadding="4"> ';
echo '
<div class="tborder"><table border="0" width="100%" cellspacing="1" cellpadding="6">
<tr><td class="windowbg2" width="100%" align="center">
<a href="http://www.xxxforum.be/index.php?topic=2263.0">';
   $result = db_query("
      SELECT
         b.ID_BOARD, b.name, b.description, b.numTopics, b.numPosts,
         m.posterName, m.posterTime, m.subject, m.ID_MSG, m.ID_TOPIC,
         IFNULL(mem.realName, m.posterName) AS realName, " . (!$user_info['is_guest'] ? "
         (IFNULL(lb.logTime, 0) >= b.lastUpdated) AS isRead," : "1 AS isRead,") . "
         IFNULL(mem.ID_MEMBER, 0) AS ID_MEMBER, IFNULL(mem2.ID_MEMBER, 0) AS ID_MODERATOR,
         mem2.realName AS modRealName
      FROM {$db_prefix}boards AS b
         LEFT JOIN {$db_prefix}messages AS m ON (m.ID_MSG = b.ID_LAST_MSG)
         LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
         LEFT JOIN {$db_prefix}log_boards AS lb ON (lb.ID_BOARD = b.ID_BOARD AND lb.ID_MEMBER = $ID_MEMBER)" : '') . "
         LEFT JOIN {$db_prefix}moderators AS mods ON (mods.ID_BOARD = b.ID_BOARD)
         LEFT JOIN {$db_prefix}members AS mem2 ON (mem2.ID_MEMBER = mods.ID_MEMBER)
      WHERE m.ID_TOPIC = 2263.0
AND $user_info[query_see_board]", __FILE__, __LINE__);

while ($row_board = mysql_fetch_assoc($result))
{
$new = empty($row_board['isRead']) && $row_board['posterName'] != '';
}
mysql_free_result($result);
if ($new)
{
echo '<img src="<http://www.mijnforum.be/kroeg1.jpg>" border="0" alt="Kg"/>';
}
else
{
echo '<img src="<http://www.mijnforum.be/kroeg.jpg>" border="0" alt="Kroeg"/>';
}
echo '</a></td>
</tr></div>';
     
echo '
</table></div>';


Anyone???