I'm the maintainer of the Unique Field module, which has been suggested as a solution for implementing a requirement that the link field have a unique value (#88037: How to avoid duplicate entries for a link field?). I'm following up on a frequent issue for people who try to do this.
Since the Link module does not cleanup URLs (like by adding "http://") before storing them, two URLs that look identical when displayed (after being cleaned up) are not stored with the same value in the database, and therefore are not easily detected as duplicate values by the Unique Field module.
Would you consider a change to the Link module so URLs are normalized before being saved?
Comments
Comment #1
mlncn CreditAttribution: mlncn commentedI'm also interested in this feature but like "the Drupal way" of cleaning up user-input content on display.
Ah. But the SQL query to find matching values is so much better if we clean up URLs on input.
Therefore, i second the request to have Link module clean up URLs.
Would a patch be accepted to have Link standardize URLs on save:
This only sort of helps, though. For my purposes i could assume that www and no www links are identical, but Link module cannot standardize that on save.
Maybe the query has to be ugly, or a separate index table maintained? Which module should this go in?
I'm also very interested in having the check done by AJAX, would either module accept that?
benjamin, agaric
Comment #2
daveparrish CreditAttribution: daveparrish commentedsub
Comment #3
aac CreditAttribution: aac commentedCould you got any solution to this problem. I am trying to develop an ajax based module for checking the duplicacy of urls stored in the database.
Comment #4
mlncn CreditAttribution: mlncn commentedaac, i'm working on http://drupal.org/project/formmsgs for Drupal 7.
Comment #5
aac CreditAttribution: aac commentedThanks for your response!! Its nice that you are developing a generic module for ajax style checking of form fields, but it is for drupal 7 only.
At present i am trying to get this functionality for Drupal 6. I have gone through each and every issue of unique field module and link module issue queues. In fact i have written a generic module for title checking and now i am trying to make another module for urls submitted by cck link field module. In fact, i have written it, but i am facing some issue. So i am looking for some help. I am mentioning the issue here, if you are able to help me in solving the issue, it would be much appreciable.
My module is based on http://data.agaric.com/node/365.
In my *.module file, i am getting the url value submitted by a user in the following way-
My SQL query function is-
And my *.js file is using following-
Now, my issue is that if i type a url (which, i know, is already available in my database) in the cck url/link field , this module shows me that this url does not exist in the database (while it should be opposite) (Actually, I checked the same sql query in phpmyadmin and it gives the 'nid' and 'title' of the node where this url value is being used.). In fact, it shows the similar behaviour for any url submitted. So i assume that either there is some issue with my sql query function or i need to convert the url in some other format before comparing it to the database value of the url.
Thanks in advance for any help!!
Comment #6
mlncn CreditAttribution: mlncn commentedHeh, that data.agaric code is mine. I just expanded on that start with some horrible hard-coded hacky, wastefully duplicated JavaScript, etc.— http://drupal.org/sandbox/mlncn/1129680
As for your difficulties, your /browser/ might be showing things as urlencoded that aren't? Also is $_GET what i use in the sandbox module? And finally if it is urlencoded perhaps it has to be urldecoded.
Comment #7
aac CreditAttribution: aac commentedI have byepassed the sql query in my main Ajax function url_ajax_check_callback() above and just tried to print the value of $urlvalue through ajax as shown below-
I have found that
is not getting anyvalue in $urlvalue.
If i use
It prints $type correctly in ajax.
Any help??
Comment #8
jcfiala CreditAttribution: jcfiala commentedWell, on the one hand I like the way the module works one.
On the other hand, I see what you mean.
Would it be possible to have a canonical field for links, where I stick what I think the canonical value would be, and you could key off of that?
Comment #9
aac CreditAttribution: aac commentedThanks a lot Jcfiala for your response!!
But i am not getting what you are saying here!! Please make it more clear as i am not an expert in development, i am only knowing more than a beginner.
I think i am stuck only to get the value typed in the url field in some variable (say $urlvalue) using $_GET. (I have disabled the title field for link module.). What would be the syntax for that?
Comment #10
DamienMcKennaThank you all for your efforts, but I'm sorry to say that the D6 version is no longer supported.