Active
Project:
userlink
Version:
master
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
20 Aug 2006 at 14:12 UTC
Updated:
20 Mar 2007 at 16:25 UTC
Hi,
Thanks for the great module. I'm trying to add a bookmarklet, jscript, javascript:location.href='http://www.mysite.com/node/add/userlink?edit[url]='+encodeURIComponent(location.href)+'&edit[title]='+encodeURIComponent(document.title)
but can't get it to work. Do you have any ideas?
Thank,
Jim
Comments
Comment #1
jonathan_hunt commentedBy default, I don't think you can pass parameters to Drupal via URLs unless Drupal expects that.
I have this bookmarklet working for me.
I made the following changes:
in the javascript
- replaced & with &
- replaced edit[url] with url and edit[title] to title
in userlink.module
- in userlink_form(), I added the following at the start of the function
HTH.
Comment #2
jonathan_hunt commentedI meant to say replaced & with &
Comment #3
marcp commentedJonathan - could you please post the javascript code in a code block for me? Also, I've got a "post to del.icio.us" button on my toolbar -- I can't remember how it got there, but it seems like del.icio.us gave me a quick and easy way to bookmark the javascript code -- do you know how we can incorporate that into userlink?
Thanks,
Marc
Comment #4
rwfaught commentedHiya folks. I was able to get a bookmarklet for Userlink working perfectly in Firefox with the following code:
javascript:q=""+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text);location.href='http://www.myspizace.com/node/add/userlink?edit[url]='+encodeURIComponent(location.href)+'&edit[title]='+encodeURIComponent(document.title)+'&edit[body]='+q;That will fill in the URL and Title fields, and it will also put any selected text on the page into the Description field -- with one caveat: if you open the bookmarklet as a new tab it just fills in about:blank in the URL field and leaves everything else blank.
I'm not a programmer, I just hacked my way through this from bits and pieces of bookmarklets I have so if there's an easy fix for that then let me know. I can handle having it open in the same window in the meantime.
Comment #5
rwfaught commented...err, the "doesn't work in tabs" thing makes complete sense. It's late (or early) and I should be in bed. I'll figure out a pop-up or some other solution to having it open in the same window later.
Comment #6
rwfaught commentedIn my sleep-deprived state this morning I also forgot to mention that I used the prepopulate module which allows fields in the create content forms to be pre-populated from the URL.
Comment #7
mloitzl commentedHi!
I would suggest the following solution (best of ;-):
Variant of the Bookmarklet: Drupal "Blog this" bookmarklet v2.0 (ish)
Since the form field names are already exposed in the html source, why don't keep them?
The (robust?) php code would be:
Maybe a little bit paranoid...
Have fun,
Martin
Comment #8
zaphod280380 commentedjavascript:q=""+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text);location.href='http://www.myspizace.com/node/add/userlink?edit[url]='+encodeURIComponent(location.href)+'&edit[title]='+encodeURIComponent(document.title)+'&edit[body]='+q;this code with prepopulate module work like a charm... but i'm not skilled with javascript and i need to open the link in a new focused window. How can i do this?
thanks in advance!