Home ›
Make the site's domain name available to a node template in DrupalMake the site's domain name available to a node template in Drupal
Submitted by Benjamin Melançon on August 29, 2011 - 5:21pm
Current approach:
<?php
/**
* Implements template_preprocess_node().
*/
function issy_preprocess_node(&$vars) {
$vars['domain'] = $_SERVER['SERVER_NAME'];
}
?>
This makes a $domain variable available in node.tpl.php and its derivatives like node--event.tpl.php.
Using 'SERVER_NAME' is preferred over the $_SERVER['HTTP_HOST'] variable which can be spoofed by the user.
Comments
Post new comment