Integration with Popups API
Berdir - March 18, 2009 - 21:57
| Project: | Privatemsg |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Description
Small feature which allows to open the send new message form on profile pages (and nodes, with my patch at #341370: Add "Send msg to author" link to selected node types) in a modal popup.
Because this can easily be done by adding a hook and a setting checkbox, It's a patch against privatemsg.module and not a separate sub-module. I don't think it makes sense to have a module for every tiny feature as, after all, every activated module slows down drupal a tiny bit, atleast with the current architecture.
Back to that feature, it works imho great and is really smooth, very similiar to facebook. The patch does also add a setting wich allows to disable it even if the popups module is installed.
| Attachment | Size |
|---|---|
| privatemsg.popups.patch | 1.74 KB |

#1
Thank you, worked as expected...
#2
Works nicely, but has some bugs.
- I have a "dashboard" page for users where I use panels to show various blocks. I have "Privatemsg links"-block there and when I click "Write new message", pop-up opens correctly, but AJAX wont find any users. Also the comment field is smaller than usually. Works fine when I click write to author link in a user profile for example.
- After sending a message to the user of a profile, the pop-up stays open. Maybe it should close after message has been sent?
#3
on my sites its not working :(
i have popups api enabled and drupal version 6.10
#4
Please include screenshots.
#5
what you think you can see :)
when i use the patch, it's nothing done since before
just on the privatemsg settings page i have the integration settings now with enabled Open "send private message" links in a popup by default but not working on inbox etc
#6
Update:
- Re-rolled against latest -dev
- Added a title to the link on the profile page
- The send new message link in the menu block is now using popups too
@Babalu
Only links on profile pages are displayed in a popup (and now the link in the block). Also make sure to clear the cache because popups module caches the hook_popups() configuration.
Some screenshots attached...
#7
oh ok.
can you make samething that the messages in the inbox can open with popups api too ?
#8
Hi
Is there some option how we can target own link (e.g. in block, etc) messages/new or messages/new/xxx for opening in popup?
Thanks
Igor
#9
@ Babalu: i'm not sure how big that use case would be... but it should be doable. if you wanted it in the short term, you could just do it with a helper module (see below).
@igorik: this patch "should" work for every messages/new or messages/new/[X] link, even one that you add yourself.
@Berdir, good work man, you're all over this module.
Here is the integration code in the patch
<?phpfunction privatemsg_popups() {
if (variable_get('privatemsg_popups', TRUE)) {
return array(
'user/*' => array( // profile pages
'a[href*=messages/new]' // Send privatemsg
),
'node/*' => array( // node pages
'a[href*=messages/new]', // Send privatemsg
),
'*' => array(
'div#block-privatemsg-privatemsg-menu a[href*=messages/new]',
)
);
}
?>
I'm wondering if doing this in a more general way instead of per page makes more sense. That way it's consistent, even if a custom link is put on a random page. Here is what I have in my helper module right now that is working well.
One effect of this universal method is that clicking the "New Messages" tab on the messages page creates a popup instead of actually going to the tab, but i think this is a feature, not a bug, and a more consistent UI. Also using "href^" means "a link that starts with X", so even messages/new/[uid] links will work as well, which is important when you are on a user's page and you want them to send a message to them. And, you have to add the js here so the TO: autocomplete will work. Thoughts?
<?php/*
* Implementation of hook_popups().
*/
function helper_popups() {
return array(
'*' => array(
'a[href^=/messages/new]' => array(
'additionalJavascript' => array(
'misc/textarea.js',
'misc/autocomplete.js',
),
),
),
);
}
?>
#10
hmmm fyi, it looks like additionaljavascript was removed from 2.0-alpha3, but it doesn't say why or what if anything replaces it. see the release notes. http://drupal.org/node/392332
#11
ok, a little more digging... it looks like the 2.0 branch is using the patch from quicksketch to allow for adding of additional JS and CSS automatically http://drupal.org/node/336641. Since the "recommended version" is still 1.3 I think we can still move ahead with the use of 'additionalJavascript', i think (total guess) that these settings will probably just be ignored in the 2.0 branch, and not cause any issues (can others using the latest 2.0 confirm that?)
@ Babalu
I tried adding popups to the existing messages for curiosity sake. I think it's actually a cool idea, but I'm still not convinced how much it adds to the user experience, especially with the bugs below. A few quick issues i did come across were:
1) all CSS didn't seem to load (see attached image) making the threaded conversation look pretty ugly. This may be better in the 2.0 branch, since it should be loading that stuff automatically. popups 1.3 requires using the addtionalCSS property to add it.
2) if you don't send a reply after reading a message, and just click cancel. It's not clear that you've already read the message since the page doesn't reload.
if you're interested, the line I added to the above function in #9 is:
<?php'a[href^=/messages/view]' => array(),
?>
#12
oops, forgot to attach screenshot. Also, changing to needs work unless berdir or others disagree.
#13
But it does not work if your site is under http://example.org/drupal/.... href* works for that and your uid example too.
Not sure.
I'm also not sure if it is a good idea to add to the read page, maybe the pmgrowl module is a better way to have something like that? http://drupal.org/project/pmgrowl
#14
Cool project! without dealing with bugs listed above, i agree popups for existing messages shouldn't be included. I see your point about the non-root installs... how about this then?:
<?php/*
* Implementation of hook_popups().
*/
function helper_popups() {
return array(
'*' => array(
'a[href*=/messages/new]' => array(
'additionalJavascript' => array(
'misc/textarea.js',
'misc/autocomplete.js',
),
),
),
);
}
?>
#15
uid example should still work now, even on non-root installs
#16
@Berdir so what do you think of the last example?
#17
@frankcarey
The only thing I have against that is that popups.module advised against using a wildcard for the path for performance reasons when I wrote my first version of that patch. But you are welcome to roll a patch/update mine with your suggestion.
#18
May I ask about the status of this function? In earlier versions of Privatemsg it worked great for me. I patched the latest dev, open the 'send user a message' link in Popups modal window and everytime I click on 'preview' or 'send' I'm going be redirected to messages/new/[uid] where the validation happens... but the ajax validation seems to not work anymore. Am I missing something or has something changed inside Privatemsg itself?
It would really be cool if this patch could go into Privatemsg where the module could check if Popups is installed or not - to show the Popups settings on Privatemsg's admin page or not.
Is it possible?
#19
Re-rolled the patch, patch applies only against 2.x-dev.
#20
Sorry if my question is stupid but I'm really not delighted regarding 2.x-dev and would like to know what's current status -> the desciption of 2.x-dev says that this code is old and shouldn't be used. Do you plan to renew the code and use it for new feature development?
And, why not implementing this patch into private msg 1.1?
Thank you very much for your efforts! :)
#21
Because the 1.x branch is stable and that means that no new features are added to that branch.
The "old code warning" is outdated, 2.x is now used to develop new features. I will update that text now.
#22
Nice, thank you very much for the info. :)
#23
Setting proper status