Return to Snippet

Revision: 55680
at February 17, 2012 00:33 by nicoknaepen


Initial Code
function yourtemplate_preprocess_html(&$vars) {
  // get the request parameters
  $reqParams = explode('?', $_SERVER['REQUEST_URI']);
  $canon = 'http://www.marlux.com' . $reqParams[0];
  // create a canonical object
  $canonical = array(
      '#type' => 'html_tag',
      '#tag' => 'link',
      '#attributes' => array(
          'name' => 'canonical',
          'content' => $canon,
      ),
  );
  //  add the canonical object to the html head
  drupal_add_html_head($canonical,'canonical');
}

Initial URL
www.marlux.com

Initial Description
For our project, this code had been implemented in the theme template.php

Initial Title
Drupal - Add canonical tag in

Initial Tags
drupal

Initial Language
PHP