Reply to comment

More Drupal meta tag work

Getting 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.

 

Reply

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
4 + 14 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.