Drupal 6 - 样式页H1标签

时间:2011-07-26 13:33:19

标签: php drupal-6

我的page.tpl.php带有标准的h1标签:

<h1><?php print $title ?></h1>

一切都与世界相关,但是,我想使用一个目标来设置我的H1标签的字体。这一切都很好,但这些都是唯一的,所以我需要在h1标签中添加一个类,以便我的所有主要部分都是唯一的。

我的想法是使用php在每个主页上抓取一些独特的东西...这个URL是唯一的,所以我抓住了:

<div class="<?php print $current_path = drupal_get_path_alias($_GET["q"]);?>"><h1><?php print $title ?></h1></div>

这工作正常,我甚至不知道PHP!但!!我的一些网址中包含数字,它们在页面代码中打印得很好但css不会与它们通信:(

所以这很好:

<div class="books-and-toys"><h1><?php print $title ?></h1></div>

然而,这不会是风格:

<div class="70s-books-and-toys"><h1><?php print $title ?></h1></div>

那么,有没有人知道如何绕过这个,或者确实,我的网页上有什么独特之处,以便我可以打印一些东西来制作div id?

非常感谢您的帮助

1 个答案:

答案 0 :(得分:0)

据我所知,至少从CSS 2.x开始,所有类名必须以-_或字母a-z开头。因此,70s-将不是有效的类名。

快速解决方法是在课程前加上:

<div class="<?php print 'title-' . $current_path = drupal_get_path_alias($_GET["q"]);?>">
    <h1><?php print $title ?></h1>
</div>

你也可以通过以下方式消除这个额外的div:

 <h1 class="<?php print 'title-' . $current_path = drupal_get_path_alias($_GET["q"]);?>">
       <?php print $title ?>
 </h1>
但是DIV很好;特别是如果你想在标题中添加内容的样式。

相关问题