Hi there,

I have a calendar page with the little ical download link showing at the bottom. I want to change the download link - make a custom (larger) image and add more explanatory text ("add these events to your calendar" or something, maybe with a link to a help page walking users through importing the ical file into outlook).

Which files / functions do I have to override to change this display?

Forgive my newbie-ness - I'm on the steep part of the Drupal curve.

Thanks in advance.

Comments

Exploratus’s picture

subscribe...

scooper’s picture

Version: 6.x-2.2 » 6.x-2.4

I added a text link preceding the iCal icon by making changes to my theme's template.php. First I found the function that displays the iCal icon - it's in folder calendar/calendar_ical, module calendar_ical.module .

Here's my code from template.php (substitute your actual theme name for YOURTHEME):

function YOURTHEME_theme(){  
    return array(
    'calendar_ical_icon' => array(
      'arguments' => array('url'),
      ),
    );
}

function YOURTHEME_calendar_ical_icon($url) {
  if ($image = theme('image', drupal_get_path('module', 'date_api') .'/images/ical16x16.gif', t('Add to calendar'), t('Add to calendar'))) {
    return '<a href="'. check_url($url) .'" class="ical-icon" title="ical">Add to your calendar '. $image .'</a>';
  }
}

To get this to take effect, clear the cache under Site configuration->Performance.

tripper54’s picture

Status: Active » Fixed

Nice one, thanks Scooper

BrightBold’s picture

I'll definitely be using that, scooper. Thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

pbfleetwood’s picture

I changed the image in CSS with the following code, which pads out the link to be large enough to fit the new button (24px x 64px, in the example) as a background.

div.feed-icon a.ical-icon img {display:hidden; padding: 0px 0px 8px 48px; background: url(../images/ical-bg.png) no-repeat;}

Notes:

  • Display:hidden is used instead of display:none, because the old icon is to be invisible, but space for it must still be allocated.
  • The padding values should equal the dimensions of the new image minus those of the original icon.
  • Naturally, the image will be in your theme's directory structure, not in the module's.
  • Use no-repeat just in case some browser (i don't want to name names) occasionally does something stupid. It can't hurt.
pbfleetwood’s picture

Version: 6.x-2.4 » 7.x-3.x-dev
Component: iCal export » User interface
Category: support » feature
Status: Closed (fixed) » Active

This issue should not be closed, but changed to a feature request, as the module should offer the flexibility of specifying the text and or the image for the iCal link.

KarenS’s picture

Project: Calendar » Date iCal
Version: 7.x-3.x-dev »
Component: User interface » Code

I decided to set Date iCal up as a new project. It can be expanded to include a Feeds parser for importing ical items and add some features to make it easier to import/export ical feeds. Plus it could have another maintainer that is someone interested in doing more work on the iCal standard. I will be deprecating the Calendar iCal module in favor of that one.

Moving this issue there.

coredumperror’s picture

Version: » 7.x-2.x-dev

Please check out the new Date iCal 7.x-2.x, then comment on this issue if you're still interested in this feature. I can't guarantee that I'll have time to implement it in the immediate future, though.

vlad.pavlovic’s picture

I think this feature is still needed (ie: the ability to override the link). The main reason is that the contextual filter from the calendar is added to the ical feed link. This happens even if no contextual filter is specified in the path (in that case, the month, week or day definition) is appended to the end of the URL.

coredumperror’s picture

You're right, I should definitely fix this. But I'm not certain what exactly to do, or how to do it. Could you explain exactly what Date iCal should be doing, so I can look into ways to fix it?

vlad.pavlovic’s picture

I think all that might be needed is checking if an argument is a part of the path, and if it's not, then just go the path itself with no arguments at all (instead of appending the argument to the end).

Having said all of that, there are two ways to get around it, one would be to check 'Skip default argument for view URL' for the other displays (Month, Week, Year, etc) Context filter. After all, that's what the checkbox was added for anyway. This adds an 'all' to the path, but that's fine, it will still cache nicely.

And the other is the approach from #2, but using the updated override, which would be 'date_ical_icon', instead of 'calendar_ical_icon' (I presume for 6.x, since that's what was specified).

So similar to the example above, for version 7.x-2.x the template.php file would look something like:

function YOURTHEME_theme()  {
  return array(
    'date_ical_icon' => array(
      'arguments' => array('url'),
      ),
    );
}

function YOURTHEME_date_ical_icon($url)  {
  $image = theme('image', array(
                          'path' => drupal_get_path('module', 'date_ical') . '/images/ical-feed-icon-34x14.png', 
                          'alt' => $url['tooltip'], 
                          'title' => $url['tooltip'])
            );
  if ($image) {
    return l(t('Add to your calendar !image', array('!image' => $image)), $url['url'], array('html' => TRUE));
  }
}

So actually, to be honest, I am not sure if anything is necessary from your end. This is probably a 'working as designed'.

coredumperror’s picture

Actually, because of the dramatic changes made between 7.x-1.x and 7.x-2.x, that might not be viable any more. Date iCal doesn't use the theme system the same way as it used to, so I don't think the solution in #2 would actually work.

AFter looking through the code, I think I know where I need to manipulate the URL to get rid of unneeded parameters, but it'll take me some time to figure out exactly how to do so.

vlad.pavlovic’s picture

The code I have posted in #12 is a working example for 7.x-2.x-dev (and worked for 7.x.2.6). The solution works, it's just a different name.

coredumperror’s picture

Status: Active » Closed (works as designed)

Really? Huh, I didn't realize that would work. Goes to show: even though I've been working with Drupal for nearly two years, I still barely have any idea what I'm doing. ;)