Drupal 6 upgrade with extra RDFa goodness

by ekes

Finally upgraded this site from Drupal 5 to 6. There's nothing special in that, it all went very smoothly and I just changed the theme again. But on the way I thought I'd get a bit of RDFa into the site - so the most interesting stuff on this, and other pages, you probably can't see.

RDFa has always made a huge amount of sense to me, and there's a push to get it into core for 7, which is brilliant, so testing a bit more in here seemed a sensible thing.

Central to implementing a bit more RDF of any sort into Drupal at the moment is the rdf module. Here it's making some nice changes to the header, and adding the name spaces. It's easy to add more that the default too - I certainly wanted Creative Commons and Web of Trust that weren't there already, for example.

Also pretty important, and I guess the way it's going to go with fields in core, is RDF CCK module. This is a lovely module, which when installed with its dependencies, will auto suggest as you type mappings from the imported vocabularies (excellent stuff :) The module's at work here on the profile nodes. However as the rest of the site is based on pretty simple nodes (title, body, with a user and taxonomy) and comments (same but without taxonomy) and no extra fields most of the rest of the RDFa magic's in the template.php and a bit in the appropriate *.tpl.php for now.

Nodes

First off with nodes just to make sure the subject is usually set I changed the first <div> in the node.tpl.php to include an about="/path/to/node":

<div about="<?php print $node_url; ?>" id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?>"><div class="node-inner">

This means even when it's on a page with multiple nodes the content inside will have correct subject

Next I wanted the dc:subject. I'll get round to integrating with some controlled topic vocabulary, but for now it's referenced on my site. Anyway for this in the THEMENAME_preprocess_node it's just a case of redoing the terms variable:

  $terms = taxonomy_link('taxonomy terms', $vars['node']);
  foreach($terms as &$term) {
    $term['attributes']['property'] = 'dc:subject';
  }
  $vars['terms'] = theme('links', $terms);

Next up the node author. For this I've overridden the theme_username to accept a $options for the link. It's not always the case that the username is an author obviously, so this you choose on pulling the display.

-function theme_username($object) {
+function THEMENAME_username($object, $options = array()) {
 
   if ($object->uid && $object->name) {
     // Shorten the name when it is too long or it will break many tables.
@@ -8,9 +8,10 @@
     else {
       $name = $object->name;
     }
-
-    if (user_access('access user profiles')) {
-      $output = l($name, 'user/'. $object->uid, array('attributes' => array('title' => t('View user profile.'))));
+    $profile = content_profile_load('profile', $object->uid);
+    if ($profile && node_access('view', $profile)) {
+      $options['attributes']['title'] = t('View @title', array('@title' => $profile->title));
+      $output = l($name, 'node/'. $profile->nid, $options);
     }
     else {
       $output = check_plain($name);

This needs a bit of thinking about for those occasions when a non-registered, anonymous, user is allowed post and enter their name and url, but it should be as easy to do the same thing on these occasions too if it were so desired (not sure if it makes sense with 'nofollow'?). After making the theme override it's then simple enough to call from the THEMENAME_preprocess_node as:

  // node author link
  $vars['author'] = theme('username', user_load(array('uid' => $vars['node']->uid)), array('attributes' => array('property' => 'dc:creator cc:attributionName', 'rel' => 'foaf:maker sioc:has_creator cc:attributionURL')));

There are lots of predicates here, for most it's clear if their object should be the URL for the user or the literal value of the name string. I'm not 100% sure over the dc:creator though, it's going to the plain text name which seemed to be the best practice suggestion when used with so many others. But, hey, I might be wrong, in which case it wants to be in 'rel'.

I'll deal with the created, updated, stuff below with the comments, because I did a bit of user display side stuff with THEME_node_submitted that complicates it more than I have with THEME_comment_submitted. The logic works the same in both.

Now this all works, except of course that if the nodes are show on the page itself the title isn't displayed by the node.tpl.php but by the page.tpl.php.

Page

I'm guessing there's a whole lot more that can be done here for site wide metadata, but so far I've just gone for the general licence, which is actually in a block, and the title. The line for the title in the page.tpl.php is as simple as:

           <?php if ($title): ?>
              <h1 about="" property="dc:title" class="title"><?php print $title; ?></h1>
            <?php endif; ?>

With the empty about it's related to the page itself, and with pages with other objects on them they will only be related if their about object is the same.

Comments

The object for this can just be the url fragment, so I've make this available as $comment_url in THEMENAME_preprocess_comment and then popped it in the <div> just as above.

The title and the user are much as the node, as is the date which I'll describe here. The wish is to add the dcterms:created (and for some nodes the dcterms:modified) both of which best have an object value as a W3C datetime. So for the comment date I've just made a THEMENAME_comment_submitted theme function overrride.

function THEMENAME_comment_submitted($comment) {
  return t('Submitted by !username on !datetime.',
    array(
      # note the additional theme() param here for THEMENAME_username() as above
      '!username' => theme('username', $comment, array('attributes' => array('property' => 'dc:creator cc:attributionName', 'rel' => 'foaf:maker sioc:has_creator cc:attributionURL'))),
      '!datetime' => '<span property="dcterms:created" content="'. date('c', $comment->timestamp) .'">'. format_date($comment->timestamp) .'</span>',
    ));
}

It's worth noting though the date 'c' switch is PHP 5 only, and it's apparently full ISO 8601.

The other difference for comments here is that SIOC can describe the relationships between them nicely. Having toyed around with various ideas of where to put sioc:has_reply and sioc:reply_of I was struggling to find anything better than an otherwise empty element, or making an 'in reply to...' link to pop into (and CSS display: none) the submitted information. I'm sure there's a better way, but for now:

  $parent_path = 'node/'. $vars['comment']->nid;
  $parent_options['fragment'] = $vars['comment']->pid ? 'comment-'. $vars['comment']->pid : '';
  $parent_options['attributes']['rel'] = "sioc:reply_of";
  $vars['parent_link'] = l(t('in reply to...'), $parent_path, $parent_options);

Another one that's bothering me is I want to identify what the content is, but encoded content is hard work, from what I gather using RSS 1.0 content is going to be the way, but was just a start.

Note

Throughout CURIE used from:-

 @prefix dc: <http://purl.org/dc/elements/1.1/>.
 @prefix dcterms: <http://purl.org/dc/terms/>.
 @prefix sioc: <http://rdfs.org/sioc/ns#>.
 @prefix foaf: <http://xmlns.com/foaf/0.1/">
 @prefix cc: <http://creativecommons.org/ns#>.
 @prefix wot: <http://xmlns.com/wot/0.1/>.

Comments

Buy Neopoints

This is a wonderful article, you have a way with words. I find myself agreeing with a lot you have brought up. You have definitely earned yourself another reader! Buy Neopoints , Neopoints For Sale , Buy Neopets Items, Buy Website Traffic, Website Hits, Increase Website Traffic

That extra RDF is a great

That extra RDF is a great feature. Help me in many ways. That was a great inclusion. You can have more info about RDF in my site.

moroccan oil

moroccan oil
Coding was never in my range. I have poor sense of coding knowledge. But I try to visit all the coding related sites to learn about it. Thank you very much.

nice

It is a very profitable post for me. I've enjoyed reading the post. It is very informative and useful post. I would like to visit the post once more its valuable content.
Beach Sarong

Thank you for another

Thank you for another essential article. Where else could anyone get that kind of information in such a complete way of writing? I have a presentation incoming week, and I am on the lookout for such information.
Laptop bags

thats great explanation about

thats great explanation about coding to drupal knowledge.i get my answer in this blog.its very attractive and easy to practice.kartu kredit mandiri.

I dont know what to say

I dont know what to say. This blog is fantastic. Thats not really a really huge statement, but its all I could come up with after reading this. You know so much about this subject. So much so that you made me want to learn more about it. Your blog is my stepping stone, my friend. Thanks for the heads up on this subject

Fourth 4th of july quotes

You make plenty of Fourth 4th of july quotes excellent points in this article however its almost impossible for me personally to concentrate on this article with the broken layout! Francis Bacon quotes

This one is very nicely

This one is very nicely written and it contains many useful facts. I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement. Thanks for sharing with us. te koop Knokke Heist

click here for rock t-shirts

click here for rock t-shirts
It was amazing to visit your site. I always have a good impression about Drupal. I do not use Linux but I like Drupal.

tankinis

tankinis
I am just illiterate about coding. But I liked visiting your site as it is designed very preciously. great job indeed.

great

i cant stop it on my wordpress site, drives me crazy always reportingtrackback spam as spam.
Cocktail Dresses

Hello

Hello there! I know this is kinda off topic however , I'd figured I'd ask. Would you be interested in trading links or maybe guest authoring a blog post or vice-versa? My website addresses a lot of the same subjects as yours and I believe we could greatly benefit from each other. If you're interested feel free to shoot me an e-mail. I look forward to hearing from you! Fantastic blog by the way!

December 2012

December 2012
Actually I do not use Linux. But I would prefer Drupal to use instead of any others. I liked the way you have presented the article.

SCR Catalyst

SCR Catalyst
Howdy this is kind of of off topic but I was wanting to know if blogs use WYSIWYG editors or if you have to manually code with HTML. I'm starting a blog soon but have no coding know-how so I wanted to get advice from someone with experience. Any help would be enormously appreciated!

hunza

I have not been able to find such kind of information throughout the search engines and internet. It's been fabelously informative to read your blog and i am going to suggest it to another fellow as well.
Aaron Belfour blog's

Racing Games One other thing

Racing Games One other thing is that an online business administration study course is designed for individuals to be able to smoothly proceed to bachelors degree programs

Write more, thats all I have

Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point. You clearly know what youre talking about, why throw away your intelligence on just posting videos to your blog when you could be giving us something informative to read?

The article content is novel,

The article content is novel, and I like to read this type of article! .Amazing and interesting concept on your website.Fantastic article and great post. amateur

I believe, you've done a

I believe, you've done a wonderful job, and it could be amazing if you wrote something else about it http://www.consumer6reporter.com

Well, it is a right thing to

Well, it is a right thing to use drupal for website as open source. Thanks.
unlock iphone steps

nekilnojamas turtas

nekilnojamas turtas
Does your blog have a contact page? I'm having trouble locating it but, I'd like to shoot you an email. I've got some recommendations for your blog you might be interested in hearing. Either way, great blog and I look forward to seeing it grow over time.

Dog harness Brisbane

Dog harness Brisbane
It was nice to know these facts about Drupal. I have been getting helped by your post. Thank you.

DxSGHbmxVXRk

Best Wishes, http://intensedebate.com/people/nudehookupswea nude hook ups web sites, 5232,

pemutih wajah

pemutih wajah
Thank you very much for these information about Drupal. I have been searching for something like this for weeks. Thank you very much.

free home business

free home business
It has been great to visit your site and read your post as it is very refreshing and interesting. It contains good information either. Keep it up.

alo

alo
This turned into quite valuable in the beginning I did not agree with this although the end it proved to be wonderful. Beneficial for every man and woman ... if you find that this info wasn't more than enough, read it once again and you will see.

Tadalafil for

rfofsjtlsb, Tadalafil sale, NSUFEru, [url=http://www.tadalafilwebbuy.com/]Buy tadalafil online[/url], JWvSFiM, http://www.tadalafilwebbuy.com/ Tadalafil sale, jORvcJT.

Generic viagra online

dabwtjtlsb, Buy cheap viagra online uk, uSWFvPg, [url=http://www.philacares.com/]Viagra pharmacy[/url], mMKUiEG, http://www.philacares.com/ The makers of viagra sued by plantiffs, tulGFxJ.

HUNZA

Great job. Well with your permission allow me to grab your rss feed to keep up to date with incoming post. Thanks a million and please keep up the delightful work.
Aaron Blog's

agGmJBrzjB

LyrgJRtZPvWRAAwhCL

Search this
prednisone and demerol
super buy cheap prednisone
prednisone patient teaching muscle weakness
buy prednisone no visa online without prescription
purchase prednisone without rx to ship overnight
prednisone dexamethasone conversion
prednisone pharmacy store
generic prednisone juneau
where can prednisone be purchased
prednisone effect on osteoarthritis
can i purchase omnipred prednisone fast delivery mississippi
prednisone apo increased appetite
drug online prednisone | osteonecrosis and prednisone dose
generic drugs prednisone success with prednisone generic
cheap prednisone anti-allergic online visa saturday delivery mississippi
simplex prednisone
order prednisone from american pharmacy
prednisone azithromycin and constipation
generic prednisone online without prescription
prednisone dose pack information
need prednisone predisone western union fast
fludrocortisone acetate prednisone
abuse of prednisone sterapred ds jcb no prescription
online prednisone pharmacy generic prednisone buy online
cheap prednisone online diners club priority mail
how long do the effects of prednisone last mood changes
prednisone and kidney scan
methylprednisolone vs prednisone taper schedule
buy brand prednisone amex
cheapest prednisone without a prescription

Buy viagra online a href

ifngijtlsb.ju, Fioricet addiction, SkPQffC, [url=http://www.thecomictorah.com/]Fioricet sale[/url], wYsnuBq, http://www.thecomictorah.com/ Fioricet 40 mg and 50 mg, qJfPdsL, Klonopin used for anti-psychotic, gnivliC, [url=http://www.panicattackwebs.com/]Prozac and klonopin[/url], NViMsQU, http://www.panicattackwebs.com/ Liquid klonopin, npEfhAr, Where can i get nolvadex, tWKudBv, [url=http://www.nolvadexwebguide.com/]Nolvadex prescription[/url], DESTJhx, http://www.nolvadexwebguide.com/ Taking nolvadex with sostonol 250, keymMXQ, Meridia, gotNUPZ, [url=http://www.frhermanpeaceandjusticecenter.org/]Meridia vs phentermine[/url], vRUXIMz, http://www.frhermanpeaceandjusticecenter.org/ Order meridia online, tFSELNn, Codeine drug, lhjvhMZ, [url=http://www.greenwaypaint.com/about-us]Effect of im codeine injection[/url], QatqweQ, http://www.greenwaypaint.com/about-us Codeine, wgSoESm, Female herbal viagra, xNPFakI, [url=http://willits.org/]Get viagra without prescription[/url], Xbmdeog, http://willits.org/ Cheap viagra, pAGaYfZ.

KwlQcBgnkwb