Closed (fixed)
Project:
Privatemsg
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
16 Jun 2009 at 05:27 UTC
Updated:
2 Sep 2009 at 17:44 UTC
hi.. apart from displaying how many new messages (custom menu), how can i create a block or snippet to display the last 5 or less/more latest messages?
anyone done this before? any help is appreciated. thanks.
Comments
Comment #1
sadist commentedanyone done or came across this feature before? no one? :(
Comment #2
litwol commentedTake a look at code how blocks are created and how we create the inbox list. combine the two methods for your purpoess.
Comment #3
timofey commentedI've spent a good 8 hours trying to figure this out. I'm new to this.
Can someone please, please hint us?
How do you display the subject of the five latest messages in a block?
Thank you!
Comment #4
naheemsays commentedHave a look at privatemsg_list in privatemsg.module file. To get the data you need to do:
where $account is the user account for the person for who you want to list the messages. Replace the number 5 with however many threads you want to show.
After that, if you want the same layout as in the normal listings, copt the form creation code from after the query in the same function.
Comment #5
berdirFor a block, I assume you just want a list of titles and no paging, you can do that with the following code
If you just want to display the content of the inbox, replace 'list' with 'inbox'.
Comment #6
timofey commentedSo I click on "Add Block" from the admin menu, I put in the code, change the input code to PHP and save it.
Do I add "echo $result;"?
The block is either empty or showing "Resource id #140".
Comment #7
berdirThe code was supposed to be used in a module. With a few small changes, it should work with the php code input format too..
- Add a global $user before the first line and replace $account with $user
- Replace "return theme... " with "echo theme..."
Comment #8
timofey commentedThat solves the problem!
You guys are wonderful!
Comment #9
berdirComment #10
sadist commentedso, is this what i'm supposed to place on my custom block?
The Block is working but nothing is being listed there. There's definitely at least 1 message inside my Privatemsg. At the top of the page, there's error message.
user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0, 5' at line 1 query: LIMIT 0, 5 in D:\Http\drupal\includes\common.inc(1655) : eval()'d code on line 3.
What could be possibly my problem here? Thanks guys!
Comment #11
naheemsays commentedread comment 7:
Comment #12
sadist commentedthanks so much!
Comment #14
Michsk commentedi tried a lot, but just cant figure out how to recreate the messages page where you see the titles, participants and the dates... its giving me a headache :P
I use the above code
coulde someone maybe help me out with this?
Comment #15
sadist commentedi have to get this working with the imagecache_profile too. so i'm opening this back again. hope there'll be some help here.
Comment #16
naheemsays commented@lasac - if you want all the fields in the normal display, why not simple call privatemsg list in the first place?
@ people developing custom functionality - you WILL need to understand atleast a little php and also read the code of the module to see what it does.
Comment #17
Michsk commented@nbz: you naild it that is exactly what i need, and for the global comment i do know a bit of php but not much. I tried looking in the module but could not find the info i needed, may i ask how you got that snippet?