代码之家  ›  专栏  ›  技术社区  ›  alvincrespo

drupal变量$head中的重复<meta>

  •  1
  • alvincrespo  · 技术社区  · 16 年前

    我正在尝试自定义page.tpl.php模板中的$head变量,因为有两个

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    

    出现,我认为这会影响到使用W3C的标记验证服务对站点进行验证。任何帮助都会非常感谢,谢谢!

    2 回复  |  直到 16 年前
        1
  •  1
  •   Mike Crittenden    16 年前

    好吧,首先,我会设法弄明白为什么你会收到这些副本。手动删除一个比修复更像是一个黑客。

    也就是说,您可以使用自定义$head template_preprocess_page . 在主题的template.php中,执行如下操作:

    <?php 
    function THEMENAME_preprocess_page(&$variables) {
        // use $variables['head'] here and do whatever you want with it, such as...
        $variables['head'] = str_replace('blah blah','blah',$variables['head']);
        // ...although that's completely untested and might not work
    }
    
        2
  •  0
  •   alvincrespo    16 年前

    这似乎是Drupal API中的一个bug,下面将讨论:

    http://drupal.org/node/451304#comment-2632954

    似乎连drupal.org都在复制内容类型的meta标记。