문제

I'm trying to figure out where the <head> for all of the pages in Drupal is (I'm using Orange theme if it matters). I have to add analytics code into the <head>.

Inside which file would I find the <head>?

도움이 되었습니까?

해결책

If you look in your theme folder you'll see page.tpl.php, that is the template for the site. You can add the code there most likely.

다른 팁

Use drupal_set_html_head() by placing this in your themes template.php file. If the function MYTHEMENAME_preprocess_page() already exists insert what is inside the {closure} brackets below (before the $vars['head'] if that exists in it as well) :

function MYTHEMENAME_preprocess_page(&$vars, $hook) {
  // say you wanted to add Google Webmaster Tools verification to homepage.
  if(drupal_is_front_page()) {
    drupal_set_html_head('<meta name="google-site-verification" content="[string from https://www.google.com/webmasters/verification/verification]" />');
    $vars['head'] = drupal_get_html_head();
  }
}

In template.php of your theme folder :

function your_theme_preprocess_html(&$variables) {  

                $appleIcon57px = array('#tag' => 'link', '#attributes' => array('rel' => 'apple-touch-icon', 'href' => '/images/ICONE-57.png', 'type' => 'image/png', 'media' => 'screen and (resolution: 163dpi)'),);
                drupal_add_html_head($appleIcon57px, 'apple-touch-icon57');

 }

One another solution is to use blocks in header these can also managed very effectively using css.

  1. All you have to do is to go to Structure->Blocks then create new block.

  2. Then select theme corresponding to it and position in which section you want to show that block.

  3. Custom html like can be added. And can be handled from that id.

It allow me to handle page structure very easily.

there is a google analyitics module that will accomplish this for you with just your key.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top