Drupal 6 - Styling page H1 tags
I have my page.tpl.php with a standard h1 tag:
<h1><?php print $title ?></h1>
All is 开发者_运维技巧well with the world, however, I want to use an aimge to style my H1 tags with font. This is all very well but these are all unique so I need to add a class to the h1 tag so that all my main sections are unique.
My thoughts are using php to grab something unique on each main page...the URL is unique so I grab that:
<div class="<?php print $current_path = drupal_get_path_alias($_GET["q"]);?>"><h1><?php print $title ?></h1></div>
This works fine and I don't even know php! BUT!! Some of my URLs have numbers in them, they are printed fine in the page code but the css will not communicate with them :(
So this is fine:
<div class="books-and-toys"><h1><?php print $title ?></h1></div>
However, this will not style:
<div class="70s-books-and-toys"><h1><?php print $title ?></h1></div>
So, does anyone know how I can get round this,or indeed, anything else that is unique about my pages so that I can print something to make the div id?
Many thanks for any help
as far as I'm aware, at least as of CSS 2.x, all class names must begin with a -
, _
or the letters a-z
. As a result 70s-
will not be a valid class name.
A quick fix, would be to prefix the class:
<div class="<?php print 'title-' . $current_path = drupal_get_path_alias($_GET["q"]);?>">
<h1><?php print $title ?></h1>
</div>
you can also eliminate this extra div by doing:
<h1 class="<?php print 'title-' . $current_path = drupal_get_path_alias($_GET["q"]);?>">
<?php print $title ?>
</h1>
but the DIV is fine; especially if you want to style contents within it in addition to the header.
精彩评论