Override viewscarousel_get_class

ppmax - January 3, 2009 - 04:18
Project:Views carousel
Version:6.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

Hi--

This is a sweet module and I've been trying to extend it "the drupal way." I copied viewscarousel_get_class function from the viewscarousel.module file and popped it into my template.php file and renamed it mythemename_viewscarousel_get_class. I then added a couple lines, the most important being:

    case 'newskin':
      drupal_add_css(drupal_get_path('module', 'viewscarousel') .'/skins/newskin/skin.css');
      return 'jcarousel-skin-newskin';
      break;

Unfortunately it doesnt appear that overriding the viewscarousel_get_class function is possible. I've also tried renaming the function phptemplate_viewscarousel_get_class but still no joy.

I'd also like to extend the viewscarousel_style_plugin.inc options_form in this manner so I can include an option for my skins in the form.

Any tips or tricks?

Thanks again
pp

Is it possible

#1

mfer - January 5, 2009 - 02:16

What you are trying to do just isn't possible. We could look into extending it. The reason it is not extend able is because the skins provided are part of the jcarousel plugin and I don't plan on supporting any of the skins.

If I did open this up for other skins to be added it would be with an api call and an outside module could add them.

This module is basically just a wrapper for the jcarousel module.

#2

ppmax - January 5, 2009 - 02:26

Thanks for the reply--I understand your reasoning ;)

I ended up modifying the viewscarousel_style_plugin.inc and viewscarousel.module files to define and return the info I needed for my custom skin. I'll just have to keep an eye out in case the module is updated ;P

PS: for s*its and giggles (even tho it took me several hours to figure it out) I added a nice effect so that the animation stops when hovering over the carousel. All I did was copy the contents of viewscarousel.js into my own script in my theme/scripts directory and added a line for a callback:
this.initCallback = mycarousel_initCallback;

Then I added a callback function that I swiped from the jcarousel samples:

function mycarousel_initCallback(carousel)
{
    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

Thanks for a great module!
pp

#3

mfer - November 4, 2009 - 22:27
Version:6.x-1.x-dev» 6.x-2.x-dev

To add more themes would require a hook in a module. I'm moving this to the 2.x-dev branch where this can be added.

 
 

Drupal is a registered trademark of Dries Buytaert.