Download & Extend

Provide token for hostname

Project:Link
Version:7.x-1.1
Component:Code
Category:bug report
Priority:normal
Assigned:jcfiala
Status:needs work

Issue Summary

That is, the string between the first occurence of '//' and the first occurence of '/' thereafter. The attached patch provides this.

AttachmentSize
link-host.patch673 bytes

Comments

#1

Reworked the patch to be more simple and (hopefully) even a bit faster.

AttachmentSize
link-host-609560-1.patch 608 bytes

#2

Oh my goodness, seems like there are still folks out there who use php4... Patch updated accordingly.

AttachmentSize
link-host-609560-2.patch 622 bytes

#3

Status:needs review» reviewed & tested by the community

checked this patch, 3 simple lines, works as expected

#4

Version:6.x-2.6» 6.x-2.9
Status:reviewed & tested by the community» needs review

Rerolled patch to make it cleanly apply to 6.x-2.9 (previous one had only offset warnings).

AttachmentSize
link-609560-4.patch 622 bytes

#5

Added some error handling as chx requested.

AttachmentSize
link-609560-5.patch 650 bytes

#6

Assigned to:Anonymous» jcfiala

Hey, 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.)

#7

Status:needs review» reviewed & tested by the community

#8

Coolness - 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. :)

#9

Status:reviewed & tested by the community» needs review

Here you are.

AttachmentSize
link-609560-6.patch 3.25 KB

#10

Downloaded 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?

#11

Here it is.

AttachmentSize
link-609560-7.patch 3.24 KB

#12

Status:needs review» reviewed & tested by the community

Looks good

#13

Hello,
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

#14

Status:reviewed & tested by the community» fixed

Committed!

#15

Status:fixed» closed (fixed)

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

#16

Version:6.x-2.9» 7.x-1.0
Category:feature request» bug report
Status:closed (fixed)» active

OK, looks like this functionality has been dropped from D7 version, but I can't find the reason. Why?

#17

Status:active» needs review

Attached patch handles this in the way D7 link fields are dealt with: it provides a link_host field formatter (with tests).

AttachmentSize
link-609560-17.patch 3.09 KB

#18

Status:needs review» needs work

Wow, 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.

#19

Version:7.x-1.0» 7.x-1.1

Attached is the same as #17, but re-rolled against 7.x-1.1. I haven't worked on the token-based approach.

AttachmentSize
link-609560-19.patch 3.05 KB