PDA

View Full Version : PM Preview v1


BluPhoenix
03-29-2005, 10:00 PM
What does this do then?
This adds a "tooltip" to your Private Message Inbox showing a preview of the pm's in your list. It aids in the removal of old pm's as you can see at a glance which messages you are deleting and also you can get a preview for unread messages to see if it's worth reading now or you can save it for later.. It's a handy little extra and I was actually quite suprised to see it wasn't a default feature of vB.

The Hack

In private.php find:
// query private messages
$pms = $DB_site->query("
SELECT pm.*, pmtext.*
" . iif($vboptions['privallowicons'], ", icon.title AS icontitle, icon.iconpath") . "
FROM " . TABLE_PREFIX . "pm AS pm
LEFT JOIN " . TABLE_PREFIX . "pmtext AS pmtext ON(pmtext.pmtextid = pm.pmtextid)
" . iif($vboptions['privallowicons'], "LEFT JOIN " . TABLE_PREFIX . "icon AS icon ON(icon.iconid = pmtext.iconid)") . "
WHERE pm.userid=$bbuserinfo[userid] AND pm.folderid=$folderid
ORDER BY pmtext.dateline DESC
LIMIT $startat, $perpage
");

REPLACE that code with:

// query private messages
$pms = $DB_site->query("
SELECT pm.*, pmtext.*,pmtext.message as pmpreview
" . iif($vboptions['privallowicons'], ", icon.title AS icontitle, icon.iconpath") . "
FROM " . TABLE_PREFIX . "pm AS pm
LEFT JOIN " . TABLE_PREFIX . "pmtext AS pmtext ON(pmtext.pmtextid = pm.pmtextid)
" . iif($vboptions['privallowicons'], "LEFT JOIN " . TABLE_PREFIX . "icon AS icon ON(icon.iconid = pmtext.iconid)") . "
WHERE pm.userid=$bbuserinfo[userid] AND pm.folderid=$folderid
ORDER BY pmtext.dateline DESC
LIMIT $startat, $perpage
");

(for those that don't like changing whole queries, you are effectively just adding the highlighted bit to the query)

{still in private.php} find:
eval('$messagelistbits .= "' . fetch_template('pm_messagelistbit') . '";');

And BEFORE it add:
$pm['pmpreview'] = strip_quotes($pm['pmpreview']);
$pm['pmpreview'] = htmlspecialchars_uni(fetch_trimmed_title(strip_bbc ode(fetch_censored_text($pm['pmpreview']), false, true), $vboptions['threadpreview']));

(again we have the important bit highlighted, this is the limit for the size of the preview, here it uses the same value set for threads in the admincp, but you can replace this with a numerical value to make pm previews, shorter or longer than that depending on your preferfence. I'd say leave them the same but that's just me ;))

=============================================
We've now finished with the fileedits, now onto the templates..
=============================================

In your pm_messagelistbit template find:
<td class="alt1Active" id="m$pm[pmid]" width="100%">


And REPLACE it with:
<td class="alt1Active" id="m$pm[pmid]" width="100%" title="$pm[pmpreview]">

.....
and now you are all done, screenshot added for those who couldn't understand my lame explination (names removed to protect the guilty so that's why it looks a bit odd) and text instructions added for those that like to archive them..

Thanks for looking at (and hopefully installing) a BluPhoenix vB Hack :tired:

T3MEDIA
03-30-2005, 12:42 PM
Do you know how many more quries this will make? Just asking.
BTW nice hack. Hucked it up.

Oblivion Knight
03-30-2005, 12:50 PM
Do you know how many more quries this will make? Just asking.0, it's editing an existing query.. ;)

BluPhoenix
03-30-2005, 01:17 PM
0, it's editing an existing query.. ;)
Yep as the wise Knight says.. Zero added queries, little extra load when viewing the pm list, as it loads all the extra text into the title tags. but as long as you keep the pm listings at their vb default or lower it shouldn't cause too much of a noticable lag to the loading of the pm listings.

Marco van Herwaarden
03-30-2005, 01:58 PM
Looks nice, but that query modification is not really needed i think. The message column is already fetched.

Just change:
$pm['pmpreview'] = strip_quotes($pm['pmpreview']);
into $pm['pmpreview'] = strip_quotes($pm['message']);


and remove the query edit.

PS Not tried it myself

BluPhoenix
03-30-2005, 02:24 PM
Although I think that'll work Marco, I prefer to define just incase that becomes the norm in future, ergo futureproofing the hack somewhat (or at least that's my excuse *g*)

Marco van Herwaarden
03-30-2005, 02:29 PM
excuses, excuses, excuses, excuses, excuses, excuses, excuses, excuses, excuses, excuses :D

But serious, every edit less is one less to worry about, and 1 less possibility to make a mistake.

BluPhoenix
03-30-2005, 03:32 PM
excuses, excuses, excuses, excuses, excuses, excuses, excuses, excuses, excuses, excuses :D

But serious, every edit less is one less to worry about, and 1 less possibility to make a mistake.
Thought you were going to start up with a rendition of..

"Spam spam spam spam. Lovely spam! Wonderful spam! Spam spa-a-a-a-a-am spam spa-a-a-a-a-am spam. Lovely spam! Lovely spam! Lovely spam! Lovely spam! Lovely spam! Spam spam spam spam!"

the way you were going then :D

True, I guess.. but I dunno, there's just something almost "leaving it to chance" about not defining it, call it controlfreakish if you will ;)

Megareus Rex
05-09-2005, 04:25 AM
Great hack! I've been waiting for this for a while. And I agree it should be a vB standard. (The preview tooltips are awesome. Saved me HOURS of thread loading, lol)