Reply to comment

More meta tag work

Now that I have my main content type collecting a meta description field I have to edit my template (For a few more days using Garland (I should have just copied Garland into the proper directory before I edited it but no worries for now)

I have edited the page.tpl.php to show the meta description from my content - (Content Type Field Alterations). After telling FCKeditor not to be used on editing that field it looks good my page has the meta description I want.

But now my front page has an empty meta description tag as there is no single node assigned to the front page. I have to add a check to see if this is the front page and if it is display the meta tag I want for the front. (I could also create a page-front.tpl.php but for now will do this)

Since Drupal does not provide for a default front page meta description I had to come up with something. (I'm sure there are other ways or modules to help with this but this works)

Since I do not use the $mission field which is created in admin - settings - site-information I edited page.tpl.php to no longer display it on the page and instead use it as my meta description. (check_plain as we do not want any html)

<?if ($is_front) {?>
    <meta name="description" content="<?php print check_plain($mission);?>" />
<?}else {?>
    <meta name="description" content="<?php print check_plain($node->field_meta_description[0]['value'])?>" />
<?}?>

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.
7 + 13 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.