Posted by NeoID on October 3, 2007 at 10:46am
Is there a way of creating a block that shows something like this:
"You have (3) new PM's and (100) unread posts"
Thanks :)
Is there a way of creating a block that shows something like this:
"You have (3) new PM's and (100) unread posts"
Thanks :)
Comments
Did this with a block snippet for PM's
What did I do:
- created a new block
- added the following code to the block
- switch on input format to php
- set acceswrites: only for login users
- I overlapped this with the login block ( login block is hidden when logged in )
the " ' . $_SERVER['HTTP_HOST'] . '/node/7" is a node with a snippet with an Iframe that contains the PM window of phpbb.
<?php global $user, $_SERVER; ?>
<!-- <div class="content-user">-->
<?php print '<form action="http://' . $_SERVER['HTTP_HOST'] . '/logout" method="post" id="user-login-form">'; ?>
<span class="login_text"><br><br><b>Welkom: </span> <?php print l($user->name,'user/'.$user->uid); ?>
<br>
<br>
<input name="op" id="edit-submit" value="Logout" class="form-submit" type="submit">
<br>
<br>
<?php
$result = db_query("SELECT COUNT(*) as nr_unread FROM phpbb_privmsgs_to WHERE pm_unread = 1 AND user_id = ". $user->uid );
$row = db_fetch_array($result);
if ( $row['nr_unread'] > 0 )
{
print ('<A href="http://' . $_SERVER['HTTP_HOST'] . '/node/7" class="unmsg_links" >' . ' You have ' . $row['nr_unread'] . ' new PM's</a>' );
}
else
{
print ("No new PM's" );
}
?>
<!--<?php print l("Logout","logout"); ?>-->
</form>
<!--</div>-->
Good start
Good start amigob. Just a suggestion, have a look at the menu code in the module, it fetches number of unread messages too, using the special column in the user table to avoid counting. I'm also not sure about the iframe or the form.
Unread posts I will look into. It's a good idea because most people get addicted to the "Recent Topics" block, and only care about what has been discussed in the past fifteen minutes or less. However, there is a catch. The topics you have visited (I don't think I care about posts, more about updated topics, but it's sort of the same thing) are stored in the cookie. That, in combination with the query to figure out what topics are new, makes this query rather expensive and unsuitable for high volume sites.
Iframe works for me
http://testweb.dyndns.biz
try it, the link to a Iframe in a node
user : wanadoo
Password : dubbellucht
Don't read the meassage please, so others can see it work.
this user will works until someone does somthing that I don't like.
code used in the node for the PM display
<?php global $_SERVER, $user;print '<iframe SRC="http://' . $_SERVER['HTTP_HOST'] . '/forum/search.php?search_id=newposts" align="top" width="100%" height="2000px" scrolling="No" frameborder="0" ></iframe>'
?>
AmigoB
Done, sort of
amigob: No doubt it works, I am just saying the creators of phpBB provided you with a more efficient way to do exactly what you are trying to do:
$query = "SELECT user_unread_privmsg FROM {$phpbbcfg['db_users']} WHERE user_id = ". $user->uid;(from my phpbb_menu() code).
Anyway, I created a block eloquently named "Forum stuff" that shows something like this.
Forum stuff
* Private messages (0)
* Unread topics (5)
* Unread posts (5)
For a demo see http://kepp.net/phpbb3 , create a new account if you don't have one already
Contrary to what I said earlier, I didn't worry about what topics you have already seen during this session, because the search page doesn't appear to care either.
You can find it by downloading a new copy of the beta. You should replace functions_drupal.php in [phpBB3]/includes , the configuration file and phpbb.module.
arkepp, that block looks
arkepp, that block looks cool!
I'm trying to copy the code from the phpbb3 module, but I can't get the "Unread posts" part to work, anyone who could provide the code that should go into the custom block?
It depends on the error
It depends on the error message?
unclosed tag in the pphpbb.module file
I think this is the correct place for this post.
In the phpbb.module file the
<a href>tag for "Unread Posts" was left open - roughly line 690. It caused the link to extend to all text following "Unread Posts" in the Forum Stuff block. It drove me crazy, I don't know if anyone else noticed this.Instead of:
$list[] = "<a href=\"$url\">Unread posts ({$row['COUNT(*)']})\n";You should have:
$list[] = "<a href=\"$url\">Unread posts ({$row['COUNT(*)']})\n </a>";Hope this helps any users that it might also be driving crazy.
Be kind to dragons for thou art crunchy when roasted and taste good with ketchup - Sherrilyn Kenyon
Be kind to dragons for thou art crunchy when roasted and taste good with ketchup - Sherrilyn Kenyon