Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
That is, the string between the first occurence of '//' and the first occurence of '/' thereafter. The attached patch provides this.
Comment | File | Size | Author |
---|---|---|---|
#21 | link-609560-21.patch | 3.09 KB | Boobaa |
#11 | link-609560-7.patch | 3.24 KB | Boobaa |
#4 | link-609560-4.patch | 622 bytes | Boobaa |
#2 | link-host-609560-2.patch | 622 bytes | Boobaa |
#1 | link-host-609560-1.patch | 608 bytes | Boobaa |
Comments
Comment #1
BoobaaReworked the patch to be more simple and (hopefully) even a bit faster.
Comment #2
BoobaaOh my goodness, seems like there are still folks out there who use php4... Patch updated accordingly.
Comment #3
alippai CreditAttribution: alippai commentedchecked this patch, 3 simple lines, works as expected
Comment #4
BoobaaRerolled patch to make it cleanly apply to 6.x-2.9 (previous one had only offset warnings).
Comment #5
BoobaaAdded some error handling as chx requested.
Comment #6
jcfiala CreditAttribution: jcfiala commentedHey, keen!
I'm assigning to myself so I'll find an incorporate it the next time I'm adding code to the Link module. (There's really quite a lot of tickets, and it's easy to lose them.)
Comment #7
chx CreditAttribution: chx commentedComment #8
jcfiala CreditAttribution: jcfiala commentedCoolness - I see chx approves.
I'll be including it either way, but for bonus love from me, create a simpletest test that shows that your token works!
(Of course, you may not want bonus love from me. :)
Comment #9
BoobaaHere you are.
Comment #10
drifter CreditAttribution: drifter commentedDownloaded the patch, created a link field containing the token, ran the simpletests - all went as expected. Maybe rename the test from testUserTokenLinkCreate2 to something more descriptive, like testHostTokenLinkCreate?
Comment #11
BoobaaHere it is.
Comment #12
drifter CreditAttribution: drifter commentedLooks good
Comment #13
ntg CreditAttribution: ntg commentedHello,
Thank you very much for this patch. It worked perfectly but I was wondering if it is possible to remove also the "www" and "com", "net" etc part of the hostname.
Thank you in advance for your help.
Nik
Comment #14
jcfiala CreditAttribution: jcfiala commentedCommitted!
Comment #16
BoobaaOK, looks like this functionality has been dropped from D7 version, but I can't find the reason. Why?
Comment #17
BoobaaAttached patch handles this in the way D7 link fields are dealt with: it provides a link_host field formatter (with tests).
Comment #18
jcfiala CreditAttribution: jcfiala commentedWow, so, I'm looking through the code for tokens, and it's pretty complex over there. Lots of things to climb through and figure out, but I think I've finally got a handle on it.
Is this the way that other fields are handling variant token outputs? It almost seems to me that we should be trying to hook into the various url detail/chain fields that the token module produces, although I'll admit I"m not entirely sure how to handle that yet. Then someone could do something like [node:field_link:host] and get the host, or [node:field_link:path] and just get the path.
But I'm up for hearing discussion on this.
Comment #19
BoobaaAttached is the same as #17, but re-rolled against 7.x-1.1. I haven't worked on the token-based approach.
Comment #20
BoobaaAttached the rerolled patch against 7.x-1.2. Still didn't manage to work on the token-based approach, though I like the idea.
Comment #21
BoobaaAttached the rerolled patch against 7.x-1.3. No tokens yet. :S
Comment #22
jcfiala CreditAttribution: jcfiala as a volunteer commentedOkay, that's pretty basic and looks good - merged into 7.x-1.x, should show up in dev soon.