Drupal v6 - Second Thoughts?

3 weeks of playing with Drupal v6 later here are a few thoughts of what I have seen so far. The overall appeal of Drupal is still there, though there are still the same inevitable hard-ships that make you wonder is this really worth all the hassle?. Please bear in mind that most of the development is geared towards the accessibility module and some of my gripes may not be that critical to others as it is to me.

Further to a request a couple of months ago regarding mobile themes for Drupal and posted too on Drupal - forum thread I decided to investigate Drupal v6 in a bit more detail. Since the request was about themes I decided to see what theming had to offer in the new version. Creating a "skin" was fairly straight forward. It is even possible to set content type headers within the template.php file. However the first hurdle that I came across that I am still facing is adding accesskeys to the primary_links variable.

In previous versions I had achieved this through module theming. However, I decided to see if this was possible just by using a theme override this time. I have tried numerous variations and am currently trying through phptemplate_links(). To my dismay though the main l() function has changed and I am really unsure on how to add the accesskey attribute to the link. In prior versions of Drupal I would have used the following:

function theme_accessibility_primary_links($links) {
$output = '';
#
if (count($links) > 0) {
$num_links = count($links);
$i = 1;
#
foreach ($links as $link) {
$html = isset($link['html']) && $link['html'];
#
$link['query'] = isset($link['query']) ? $link['query'] : NULL;
$link['fragment'] = isset($link['fragment']) ? $link['fragment'] : NULL;
#
if (isset($link['href'])) {
$output .= l($link['title'], $link['href'], array_merge($link['attributes'], array('accesskey' => $i)), $link['query'], $link['fragment'], FALSE, $html);
}
else if ($link['title']) {
if (!$html) {
$link['title'] = check_plain($link['title']);
}
$output .= $link['title'];
}
$output .= ' | ';
$i++;
}
}
return empty($output) ? '' : substr($output, 0, -3);
}

I would then call the menu: <?php print theme('accessibility_primary_links', $primary_links) ?> However, this does not work in Drupal v6. To this end the current code that I have is as follows, though it does not add anything to the links.

function phptemplate_links($links = array(), $attributes = array('class' => 'links'))
{
$delimiter = " | ";
// Display the left cap of the 'button bar'
//print "[";
$link_count = count($links);
$current = 1;
$output = '';
foreach ( $links as $lnk ) {
// Print the link
//print_r($lnk); //Array ( [title] => TITLE [href] => # [attributes] => Array ( ) )
$output .= l($lnk['title'], $lnk['href'], array('accesskey' => $current, 'title' => $lnk['title']) );
// Only print the delimiter if not the last link
if ( $current < $link_count ) {
$output .= $delimiter;
}
$current++;
}
return $output;
}

This is where I am at currently. It is driving me nuts. Why is it so hard to amend these links to make your site more accessible to others? Any comments or help would be very much appreciated.

Comments

Drupal has never been easy...

Hello Jamie,

First, I would like to thank you again for the accessibility module and it's themes. It's very cool to pull out a mobile device and access a site...right then and there.

I've been around Drupal a long time. I was there when Dries himself (founder of Drupal) still answered questions! The thing that has ALWAYS pissed me off about drupal is that the API's, functions, and just about anything else in the codebase changes so dramatically from version to version. Now, I believe there to be business reasons to this as it's popularity has exploded and many people have built businesses around Drupal. Constant changes means, upgrading, which we all must do eventually (or be stuck with an unsupported version i.e. 4.7) is a huge pain in the arse to non programmer types. So, they must pay someone to do it. Hence, all these businesses around Drupal. Everything from theming to hosting. Don't get me wrong, out of the box Drupal is extremely powerful, but it has a learning curve and most professional applications of Drupal use custom or third party modules. The core developers say it's due to code improvements. I say bull****. Dries himself just started a company and 7 million dollars in financing. So, control over the codebase, which he has, is why he got funded. Nothing more, nothing less. Hey, we all have to eat.

With all that said, I still say Drupal is the best CMS available. Nothing else comes close, in my opinion. I have looked at literally 200 CMS's, both open source and not, in PHP, ruby, python, java and so on. The Drupal codebase, which Dries intentionally tries to keep small, is very clean, well written, and easy to follow. Modules plug in easily and cleanly. However, Drupal is more useful for developers than a layman.

To answer your question "Why is it so hard to amend these links to make your site more accessible to others?"...because the people who control the codebase have some masterplan that will obviously benefit them BUT they cannot alienate their userbase...so they go only as far as they can with the changes.

In anycase, I'm not upgrading anything until the accessibility module gets ported! You got me hooked on your module and I am grateful that you want to port it. In all honesty, your module (or something like it) should be in core. To ignore mobile users is HUGE blunder. Just my two cents.

cheers,

wim

Thank you

Hi Wim,

Thank you for your kind words.

Just to add that over a week later, I am still no closer to a solution on how to theme $primary_links within template.php or anywhere else for that matter :(

Br

Jamie
Making Drupal Mobile

Theme available at last

Well, after a couple of weeks, it is available on this site at least!

I have one more article to write on "how to add accesskeys to links" here,
then development work should start on the accessibility module.

Hope people find it useful!!

http://www.skiffie.com/mobile/theme-files/v6/1

Br

Jamie
Making Drupal Mobile

Syndicate content