Metatags - Dublin Core or Custom

Events happening in the community are now at Drupal community events on www.drupal.org.
brendan.lynch's picture

Hi folks,
I need to add custom metatags to nodes in particular I need to add the Dublin Core set eg "[meta name="DC.Creator" content="My organisation etc" ]". There are over 10 tags. Can I use nodewords or node (key)words module or is there a better way?

many thanks - Bren

Comments

Node words

alanburke's picture

http://drupal.org/project/nodewords
is pretty much ready for D6.

I haven't used it for DC tags - I haven't used them very much.

Depending on your use case, and how much you intend to customise the DC tags,
you could just put them in your page.tpl.php file.

Regards
Alan

MetaTags

brendan.lynch's picture

Hi Alan
Tnx for reply. I need a DC set for each node. I could pop most into the page.tpl.php file (hard type or file include?). But DC.type & DC.subject will vary from page type eg Press release Vs Price statement Vs Policy doc etc. Also CD.date created is another awkward one. Could one bodge nodewords?
Bren

Metatags

brendan.lynch's picture

Alan,
UPDATE: trick use of "print" the €title & $base_path vars in the page.tpl.php file - metatags area gets me far down the road. Do you know the €variables that give the node creation and edit dates. Can they be populated into the page.tpl.php file?

Ta! Bren

you should be able to do a

scor's picture

you should be able to do a lot via template.php, or worst case via a new module of your own. The best place to read on that is the Theming guide. The devel might be helpful here too as it comes with a theme developer module (Drupal 6).

Progress on meta tags re node dates

brendan.lynch's picture

Here's some code that works.
Put this or similar in your page.tpl.php file

1

<?php
$node_array
= get_object_vars($node);
?>

2
<?php
$changedstmp
= $node_array["changed"]
?>

3
<?php
$node_changed_date
= format_date($changedstmp)
?>

4
<?php
$createdstmp
= $node_array["created"]
?>

5
<?php
$node_created_date
= format_date($createdstmp)
?>

6    <meta name="DC.Date Created" content="<?php print $node_created_date ?>" />
7     <meta name="DC.Date Modified" content="<?php print $node_changed_date ?>"/>

Explanation:
Clean theme has this funtion in the "template.php" file
function phptemplate_preprocess_node(&$vars, $hook) {
$node = $vars['node'];
Which makes a stdclass object called €node available. You could put this in your template.php file

Line 1 gets the $vars out of €node and into an array called $node_array
Line 2 gets the value for the key "changed" into $changedstmp
Line 3 formats this value to a date because its a unix time stamp ie number of seconds from 1970 (verry long number)
Line 6 pops this date (dd/mm/yy) into the html meta tag in the page.tpl.php file.
Lines 4,5 & 7do the same for the node created date

There's probably a more elegant way to do this but it works.
Many thanks for help & advice given.
Bren

Ireland

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: