Closed (fixed)
Project:
Link
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
24 Jun 2010 at 15:02 UTC
Updated:
26 Dec 2019 at 14:59 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
rcross commentedI forgot to add - this is particularly useful when moving between a staging/production (or any other moving of url)
Comment #2
rcross commentedcross posted #836722: Support converting cck link paths to internal links with pathologic in case there is some synergy.
Comment #3
jcfiala commentedI agree, that would be interesting. Perhaps someone will give us a patch? :)
Comment #4
sos4nt commentedHere's a simple patch that converts an alias back to the system / internal path before saving:
my/alias/path -> node/2
Comment #5
damienmckennaThe patch doesn't take into consideration the language argument of drupal_get_normal_path(), which could lead to problems.
Comment #6
damienmckennaHere's a version of the above patch for d7, while we're at it.
Comment #7
damienmckennaLets get some feedback from people who run internationalized sites.
Comment #8
damienmckennaAnother item that should be considered - should it be able to strip off the hostname & base_path too? E.g. if I paste in "http://www.example.com/newsite/products/green-shiny" should it be turn that into "node/123"?
Comment #9
rcross commentedstripping off the hostname & base_path were the main things I was thinking of when considering this. What i find is a very typical use is that an untrained (or lazy) content editor will just copy the url of the page they want from the url, and then paste it into the link field.
Comment #10
damienmckennaTry these, they first try stripping off the global $base_url & system base_path() and then check the path, then it tries the full path. I added the base_path check first as it would probably be the most common use case.
Comment #11
timofey commentedThis is a must for the module!
#10 worked great - Please add it to the module.
Comment #12
mstrelan commented#10 no longer applies to D7, and has some issues such as a missing brace. Update patch attached.
Comment #13
ranavaibhav+1 for this feature.
Comment #14
askibinski commentedrelated: #1370926: Having autocomplete for internal links
Comment #15
rooby commentedThe drupal 6 patch in #6 still applies with a little offset.
One problem with it is if the user enters a link to the sites home page it gets replaced with an empty string.
Then when you edit and save the page again you get issues.
This could be fixed if we were allowed relative links with a preceeding slash.
Anyway, this homepage case needs to be addressed in some way.
Comment #16
rooby commentedMaybe in that one case it should be replaced by
<front>?Comment #17
seanbThe patch in #12 works for me! Thanks.
Comment #18
drupa11y commentedAn excellent solution in my opinion is the one of this module: https://drupal.org/project/universal_reference
This module more or less a combo of the link module and the node_reference module.
It creates a field type which may both refer to an external URL (if an http:// link is entered) or autocomplete on node titles, to refer to internal nodes.
You can also specify a custom title or use the referenced node title or URL as default title.
Comment #19
kay_v commentedThe patch in #12 worked cleanly for me against 7.x-1.2 (last stable release). Will test against dev. It would be great to have this patch committed :)
Comment #20
ciss commentedRerolled against HEAD (commit 7dc306c, 2014-05-12). I guess the only thing that's missing now is a configuration option.
Comment #21
jcfiala commentedI am keeping an eye on this issue. Please make sure that patches that are created continue to pass the tests in the module.
Comment #22
joachim commentedI don't understand what the 2nd pass if for here.
Comment #23
joachim commentedAlso, I think this is incorrect:
For example, my local dev site is at http://localhost:8888/workshop/.
$base_url is http://localhost:8888/workshop
$base_url . base_path() is http://localhost:8888/workshop/workshop/
Comment #24
joachim commentedHere's the patch from #20, rerolled, with in addition:
- field setting added
- tests added
I still don't understand the 2nd pass (see comment #22), or the business with the base path (comment #23) -- but it works :)
Note that for the field setting to work, I've changed the function signature of _link_process(). But as it begins with a _ it's considered an internal function to this module, therefore we're not breaking API.
Comment #25
damienmckennaI've rewritten the original patch to a) have an option to control whether it checks for a system path, b) rewrites the logic to be a little easier to follow. Also, comments.
Comment #26
damienmckennaNeed to combine the two patches.
Comment #27
damienmckennaI've merged my updated logic from #25 with joachim's patch.
Comment #28
joachim commentedPatch 27 is missing the tests I added in patch 24.
(Also, how did you get the testbot to notice your patch?!)
Comment #29
damienmckennaDoh! Here's the missing file too.
Comment #30
damienmckennaI think I broke something when I was uploading #25 as it complained that you'd change the files list when I submitted the form.
Comment #31
joachim commentedHere's an updated patch -- changes from #29 are just:
- whitespace in test file
- clearer messages in test assertions.
Setting to needs work, as:
Not sure what this should say!
Comment #32
Anonymous (not verified) commentedGreat work!
I confirm that #31 works just fine.
Comment #33
esbite commentedI have a site running on mixed https/http. Since this patch always selects https when available, any link using http won't be converted. Why not include both http/https in the array of base paths to check?
Also, my site is multilingual, but the language path is not removed, resulting in broken links.
http://example.com/sv/fancy-alias
is saved as
sv/fancy-alias
which results in links turning into broken
sv/sv/fancy-alias
Also, shouldn't it save the permalink (node/123) instead?
Otherwise, great idea, would really love for this to be included in the module.
Comment #34
ciss commentedRerolled #31 against 7.x-1.x HEAD (3cfdc18).
Removed incomplete comment mentioned in #31, fixed case in LinkConvertInternalTestCase::setUp().
Comment #36
Adirael commentedPatch in #34 works for me in a multi-language site on 7.x-1.17, even if tests are not passing.
Comment #37
idebr commentedSetting back to status 'Needs review' now the automated tests are passing again.
Comment #38
nedjo#33 indicates this is not working with language path prefixes.
Comment #39
Paul Lomax commentedHere is a patch, I also added a link_base_paths global so extra base paths can be added (much like Pathologic). I also noticed there were some instances where the leading / (i.e base path for most sites) wasn't being removed so it was silently failing because get_normal_path doesn't like paths that begin with a /.
I also added the language negotiation work, which simply removes the language negotiation part of the path before attempting to normalise it.
Comment #40
johan den hollander commented#39 patch failed to apply to 1.7 version.
I updated the patch, one change in the .info file.
Comment #41
ciss commented@Johan den Hollander Your rerolled patch appears to be incomplete.
Comment #42
johan den hollander commentedOops. You're right about that.
Retry.
Comment #43
damienmckennaComment #44
damienmckennaThe setUp() method on the test was off, this should work.
Comment #45
damienmckennaComment #47
damienmckennaCommitted. Thank you.