Theresa Arzadon-Labajo

How to extract link from Node:Link

Posted by Theresa Arzadon-Labajo (tarzadon) on Dec 08 2010
Tech Stuff >> Drupal
When using Drupal Views and outputting Node:Link, sometimes you just want the link and not the whole HTML href.

In my views theme, I parse out the href with:
$lnk = preg_replace('/<a href=\"(.*?)\">(.*?)<\/a>/', "\\1", $field->content);
Then I construct the URL with:
print $base_url.$lnk


Another way to do this is to use Node:Nid instead of Node:Link.  Then, in the theme file, use drupal_get_path_alias to return the alias (if you don't want the URL to be "node/XX".
print $base_url."/".drupal_get_path_alias("node/".$field->content);



Last changed: Feb 27 2020 at 4:12 PM

Back