I need to create links that contain | and other weird characters used by some web developer somewhere. But the links won't validate. Here is an example

http://dcarts.dc.gov/dcarts/cwp/view,a,3,q,528461,dcartsNav,|31608|.asp

So far I uploaded the links into a text field so I could get the data into my site. But I want to put them into link fields and can't make that happen.

Thx

Comments

druppeler’s picture

One way to achieve what you want to do is the following:

Download and enable the cck computed field module - http://drupal.org/project/computed_field

Create a text field and put your URL in there.

Create a computed field and use some code similar to this (I have four CCK text fields in the code below but you would only need one):

$var_field_listing_street_address = $node->field_listing_street_address[0]['value'];

$var_field_listing_city_town = $node->field_listing_city_town[0]['value'];

$var_field_listing_state_prov = $node->field_listing_state_prov[0]['value'];

$var_field_listing_country = $node->field_listing_country[0]['value'];

$url = "http://maps.google.com/maps?q=".$var_field_listing_street_address."+".$var_field_listing_city_town."+".$var_field_listing_state_prov."+".$var_field_listing_country;

$node_field[0]['value'] = "<a href="."\"".$url."\""." target=\"_blank\">Google map</a>";

This code goes into the "Computed Code:" field of the computed field module.

This way, the URL is not being validated by any module such as the link module.

I use this to create a map link and it works well.

Hope this helps.

rsbecker’s picture

Thanks for the suggestion. But it is totally impractical for the number of url fields I need and for the variety of strings that would have to be escaped to make it work. Each record has 10 url fields, some of which hold more than one value, and there are bout 60 records. I'm using views to display them.

I guess an alternative would be to set the view to rewrite the text field and previx with

dqd’s picture