Reply to comment
More Drupal meta tag work
Submitted by matt on Wed, 07/29/2009 - 18:52Getting my meta description tag working how I wanted went well (Content Type Field Alterations More meta tag work) until I visited the taxonomy page and any other pages that weren't a normal node or the front page.
On the taxonomy pages I get an empty meta description tag - <meta name="description" content="" /> which is probably worse than nothing at all. So for the quick fix:
<?if ($is_front) {
?>
<meta name="description" content="<?php print check_plain($mission);?>" />
<?
}else {
if (isset($node->field_meta_description[0]['value']) && strlen($node->field_meta_description[0]['value'])>0){
?>
<meta name="description" content="<?php print check_plain($node->field_meta_description[0]['value'])?>" />
<?
}
}?>
Just like the entry from More meta tag work but now I ad in a check to see if there is a meta description field and make sure it has some content other wise do not display anything.
Now I have to find out how to tell if I'm on a taxonomy listing page and come up with a description for that page (Should be easy as in the taxonomy creation you can enter a description for it. I could also come up with a basic description but use the taxonomy term where needed and use that not only as a meta description but also as a bit of text before the listing of articles that share that term.
