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.
More like this
- Testing assisting module: set configurations through site's URL
- JavaScript Bookmarklet to open a web site's path in a new window with a different base URL
- Mix site's blog posts with aggregator feed posts?
- Variables available in _phptemplate_variables for node templates
- Use h1 for front page site name and strong for interior pages' site name display


Comments
Post new comment