Applying CSS styles to $calendar_links

muckermarc - July 8, 2009 - 16:12
Project:Calendar
Version:6.x-2.1
Component:User interface
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

Hello,

Not sure if this is a core Drupal issue, or with the Calendar module... I'm trying to style $calendar_links[] - i.e. the links at the top of a Calendar page with text "Week, Day, Add+".

The HTML produced is:

<ul class="links">
<li class="0 first">
<a rel="nofollow" href="/calendar/2009-W28">Week</a>
</li>
<li class="1">
<a rel="nofollow" href="/calendar/2009-07-08">Day</a>
</li>
<li class="2 last">
<a rel="nofollow" href="/node/add/show?destination=calendar/2009-07-08">Add+</a>
</li>
</ul>

Ideally I want to style each li element individually (to drop in a graphical background image as a button). However the class names each have a numeric identifier (0,1,2 etc) which is not valid CSS and is ignored by Firefox.

Any ideas on how I can over-ride the numeric class names and use text-based ones (cal0, cal1, cal2 for example)?

Cheers, M

#1

fred0 - October 14, 2009 - 00:39

I'm also having this problem. Looking into it, I see that the calendar-main.tpl.php file calls theme().
<?php if (empty($block)) print theme('links', $calendar_links);?>

Looking at the Drupal API, theme() with the hook of 'links' appears to be the same thing as calling theme_links(). So, looking at theme_links(), one finds the culprit in the foreach() loop for the li items which sets the class as the numeric key.

The solution is to override them_links() in your template.php of your theme.

#2

muckermarc - October 14, 2009 - 09:47

Hi Fred0,

Many thanks for the tip - I ended up styling all the links the same on that particular site, but will use your technique in future sites.

Cheers,

Marc

 
 

Drupal is a registered trademark of Dries Buytaert.