It would be nice if you were able to add onclick events which supported some type of configuration. what i'm looking to do is add a link to a pdf in a content type. with the onlclick element i can add google analyitics tracking in order to track the number of pdf downloads.

just a suggestion.

Thanks.

CommentFileSizeAuthor
#5 link_onclick.patch8.13 KBquicksketch
#4 link.patch3.89 KBrestlesscoder

Comments

guillaumeduveau’s picture

I second this.

quicksketch’s picture

I wouldn't mind adding this functionality. Any patches posted will gladly be accepted. Since link fields already store an 'attributes' column in the database, the 'onclick' attribute could simply be added to the list.

quicksketch’s picture

Version: 4.7.x-2.0 » 5.x-2.0

Except the 4.7 version is no longer supported. I'll post to the 5.x version. If 2 patches are submitted (one for each) I'll still post to 4.7.

restlesscoder’s picture

StatusFileSize
new3.89 KB

Here is a patch for 5.x that adds support for the onClick attribute. You can either specify a static value in the field configuration, or allow the user to type in a value themselves on a per-node basis. Thanks to quicksketch on #drupal for guidance. It is based on 5.x-2.1 though; sorry about that—I didn't realize there was a newer version.

quicksketch’s picture

Version: 5.x-2.0 » 5.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new8.13 KB

As I said before, I like the idea of adding onclick support but I haven't had the time to properly implement it. Starting with restlesscoders patch, I updated it so that it will effectively kill the 'target' attribute in a mostly friendly way. Basically we'll provide the users with a few handy starter "onclick" attributes, such as "open in new window" and "open in root window" (replacements for target). Then provide an upgrade script that converts previous target attributes to onclicks.

I'm still really short on time these days, and I didn't extensively test this code. Please review and then we can work on porting to 6.x.

I also changed the storage and printing from "onClick" to "onclick", since Drupal uses all lowercase HTML attributes.

quicksketch’s picture

I'm in no hurry to add this functionality. If it's possible to get some community testing I'd appreciate help reviewing and testing.

restlesscoder’s picture

Where can I download the latest version of the link module to use with this patch? I only see 5.x-2.1 available on the site. Thanks.

quicksketch’s picture

This patch hasn't yet been committed. You have to apply it to test it out. When the issue has been marked "fixed" the changes have been committed.

restlesscoder’s picture

I understand that I have apply your patch to the link module. What I'm asking, though, is what version of the link module do I need to use when applying the patch? I tried downloading 5.x-2.1 (the same version I based my patch on, and the latest/only 5.x version available for download from http://drupal.org/project/link), but the line numbers do not line up. I am assuming you based this patch on a different version. So I repeat my question: where can I download it?

quicksketch’s picture

Oh sorry, from the "Releases" section under the Webform project page: http://drupal.org/node/74971/release

Scroll down until you find the 5.x development version. Also, you can checkout the latest version of link module using CVS (http://drupal.org/node/321). Get the DRUPAL-5 or DRUPAL-6--1 branches for the latest code. You can also browse the CVS repository.

restlesscoder’s picture

Thanks for the information, and your work on the patch. I tested it with the DRUPAL-5 branch and it works fine, though so far I am only using the "Allow the user to specify a custom onClick value" option. I'll post another comment if I find any problems, but so far this patch seems effectively address the issue.

quicksketch’s picture

Status: Needs review » Needs work

This patch isn't going to make it into the 2.2 version because I realized that we'll also need to update the Views integration (which depends on the target attribute currently).

dqd’s picture

Status: Needs work » Fixed

Issue date expired ...

For any feature request please take a look on the link module versions for Drupal 6 and Drupal 7 with much more features and better server and web standart support since Drupal 5 is not supported no more officially.

The stop for Drupal 5 support: Since we have to catch up to get ready for the final Drupal 7 release and have to deal with many feature requests for the Drupal 6 and Drupal 7 version of the link field module, we sadly have to annouce the stop of Drupal 5 support. The files will stay for any individual use or customization, but any support in the issue queue and in the forums has expired from now on.

Sorry and thanks for understanding.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.