I created a new field for URL. What would the best way to replace certain strings in the URL when outputting the field into the field--field_url.tpl.php file be?
For example, in http://example.com/master/m/ I need to remove the "http://" part, and replace master with slave.
It is a single field; there will be no foreach()
loops.
==== edit after using preprocess === i got a undefined index: field_url
with the devel i get this
field_url
und
0
value
i put in the preprocess
$link = $variables['field_url'][LANGUAGE_NONE][0]['value'];
$link = str_replace('http://', "", $link);
$link = str_replace('master', 'slave', $link);
$variables['link'] = $link;
is this right?
====== entire hook =======
function lessxless_preprocess_field(&$variables)
{
$link = $variables['field_url'][LANGUAGE_NONE][0]['value']; // grab value
$link = str_replace('https://', "", $link); // trim http://
$link = str_replace('master', 'slave', $link);
$variables['link'] = $link;
}
sites/all/themes/lessxless/template.php