I have been working on this for a few months now off and on. This is how I envision views slideshow working.

Views slideshow is a really generic api consisting of 2 parts.

  1. Slideshow
    • Cycle
    • imageflow
    • Carousel
  2. Widgets
    • Pager
    • Controls
    • Counter

Everything becomes a plugin for those. We then provide generic javascript hooks to access actions between the 2.
ex. every time a slide changes the slideshow will fire a change event that will be sent to the pager and the pager will handle what happens to it when a slide changes. In a normal pager this may mean the correct pager will get an active class. In a carousel pager this may mean it moves to the associated pager and gets an active class. But the key is that the pager handles this action.

The idea is that we will be able to combine different pagers with a different slideshow, or different pagers with different controls with a different slideshow.

I will soon attach a patch that has the beginnings of it. It still will need some serious work. There isn't a great deal of commenting so It may be hard to follow, but I wanted to get my ideas out so people 1) understand that I'm still working on this and 2) can provide some input or patches on how to make this better.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mfer’s picture

subscribe

redndahead’s picture

Status: Active » Needs work
FileSize
35.24 KB

Here is the patch

redndahead’s picture

Status: Needs review » Needs work

I'm going to keep a list of hooks I'm using and where to keep help keep them straight.

Views Slideshow (api portion)

  • hook_views_slideshow_slideshow_types

    Define a type of slideshow. This would be something like cycle, imageflow, ddblock etc.

  • hook_views_slideshow_slideshow_type_form

    Define form fields to be displayed in the views settings form. These fields would help configure your slideshow type.

  • hook_views_slideshow_option_definition

    Set default values for your form fields specified in hook_views_slideshow_type_form

  • hook_views_slideshow_options_form_validate

    This is run like hook_validate for when the slideshow settings are saved.

  • hook_views_slideshow_options_form_submit

    This is run like hook_submit for when the slideshow settings are saved.

  • hook_views_slideshow_skins

    Define a skin or multiple skins to be available to the end user.

  • hook_views_slideshow_widget_info

    Define a new widget. Example of widgets are pagers, controls, counters. This doesn't define a type of pager just that a pager is a type of widget.

  • [widget-type]_views_slideshow_widget_form_options

    Form fields to be added for a specific widget type. Example of a widget type would be views_slideshow_pager or views_slideshow_slide_counter.

  • hook_views_slideshow_js_method_register

    When a views slideshow javascript event is fired it checks to see if one of the methods specified here implements it.

Views Slideshow Javascript Events

  • viewsSlideshowPause

    Call this to pause the slideshow.

  • viewsSlideshowPlay

    Call this to play/resume the slideshow.

  • viewsSlideshowNextSlide

    Call this to move the slideshow to the next slide.

  • viewsSlideshowPreviousSlide

    Call this to move the slideshow to the previous slide.

  • viewsSlideshowGoToSlide

    Call this to move the slideshow to a specified slide number.

  • viewsSlideshowTransitionBegin

    Call this when the slideshow transition is beginning.

  • viewsSlideshowTransitionEnd

    Call this when the slideshow transition has completed.

Views Slideshow Pager Widget

  • hook_views_slideshow_pager_settings

    Settings that define a pager type and the fields that should be shown.

redndahead’s picture

FileSize
36.84 KB

This one removes some testing code and also fixes remaining issues with adding settings into views.

Next will be theming code to make sure everything renders correctly. Then javascript to get all the events that need to fire.

redndahead’s picture

FileSize
41.11 KB

I was wrong. There were quite a few issues left in the last one. Mainly on setting default values.

This one sets default values for each field. Fixes some typos that were causing some php errors. It adds a lot more commenting to the settings generation (views_slideshow.module and views_slideshow_plugin_style_slideshow.inc). Also better weight handling based on number of widgets (this still needs work in some places specifically theming).

redndahead’s picture

FileSize
50.61 KB

This one takes care of the theming. Now everything seems to be rendering correctly. Here are some of the bigger changes.

  • Numbered and thumbnail pagers are removed. These can be handled by fields. Only downside is when someone wants to use node instead of field, but we'll cross that bridge when we get to it.
  • Skins lost the power to choose location of widgets, type of widget etc. Not sure if I want to put this back in and/or add a description which can show up in a fieldset below the skin selection.

Going through this I think we are going to lose the legacy versions because they won't fit in with the main module. I tend to take the drupal view of making solid changes and not looking back, but people will hate me. And I don't like to be hated either. So unless someone has a reasonable way to keep them in they are out.

All that's left now is getting the javascript working. Which is going to be the trickiest part.

redndahead’s picture

To implement the javascript we'll need to make sure we cover the most common functions done in a slideshow. Here is a beginning list any others?

  • Pause Slideshow
  • Resume Slideshow
  • Next Slide
  • Previous Slide
  • Go to a specific slide number
  • Slideshow has begun transitioning
  • Slideshow has finished transition
miro_dietiker’s picture

Sounds great!

Please don't forget that there might be animation elements in the showcase that might want to synchronize with the slideshow.

For example we implemented a youtube extension that starts video playback if a slideshow is reached... and continues if the playback is completed.
While this rotation i still understand the slideshow rotation to be active, while sliding is temporarily suppressed.

So in my understanding clean js extensibility is at least as important as drupal hooks.

redndahead’s picture

Yeah in that case you would call a viewsSlideshowPause and then everyone who needs to know if the slideshow can pause can implement [hook]_viewsSlideshowPause and it will fire that hook.

Right now I'm running into issues with jQuery cycle which I have asked the maintainer about fixing it. Hopefully I'll hear back soon.

mfer’s picture

What jQuery cycle issues have you run into?

redndahead’s picture

So here is the gist of what my problem was. In jquery cyle the before event would fire on cycle load. I get what is the active slide from that. There are two ways to get the slide in the before event. opts.currSlide and opts.nextSlide. They would return like this.

opts.currSlide
cycle load: 0
first transition: 0
second transition: 1
third transition: 2
etc.

opts.nextSlide
cycle load: 1
first transition: 1
second transition: 2
third transition: 3
etc.

I suggested to the maintainer that it doesn't fire the before and after events. Instead create a slideshowLoad event that fires when the cycle loads.

I have written a workaround for now like so

var slideNum = opts.nextSlide;
if (typeof settings.processed == 'undefined' || !settings.processed) {
  settings.processed = 1;
  slideNum = (typeof settings.opts.startingSlide == 'undefined') ? 0 : settings.opts.startingSlide;
}
redndahead’s picture

FileSize
60.12 KB

Alright it's ready for testing. Please test so we can move forward.

redndahead’s picture

Status: Needs work » Needs review
AdrianB’s picture

Subscribing.

redndahead’s picture

FileSize
60.15 KB

I adjusted the api list here: http://drupal.org/node/991708#comment-3804954

There are still some problems in the latest patch that needs to be addressed, but can be in a follow up issue.

  • It will not activate the slide if you hover over the pager.
  • It will not activate the slide if you click the pager.
  • Probably want to add something like hook_views_slideshow_pager_settings to the controls. So different types of controls can be added.

In this patch I changed hook_views_slideshow_type_form to hook_views_slideshow_slideshow_type_form

redndahead’s picture

Status: Needs work » Needs review

By the way, now that the rewrite is completed, I think the legacy modules will not be able to be included. So a break from the old...again. sorry

redndahead’s picture

FileSize
287.28 KB

Tar of module with patch as requested.

snufkin’s picture

Status: Needs review » Needs work
FileSize
60.47 KB

Few suggestions:

- lets make an api.php so api module can parse it (attached)
- the theme folder is missing from views_slideshow
- changed signature on _views_slideshow_widget_form_options, it should take form by reference (and should not be passed by reference, because that doesn't work in php 5.3, http://php.net/manual/en/language.references.pass.php)
- changed calls where vars are passed by reference

snufkin’s picture

Meh no php file is allowed to upload. Just remove the .txt extension.

snufkin’s picture

FileSize
60.97 KB

More work done. Changed the way the forms are defined from altering by reference to returning the form - I am not sure if we should go with this, or passing as reference, I feel using module_invoke is a bit more drupal-close.

I have a bug though, for some reason I can't get my slideshow type out when the view is rendering. The option is set on the configuration page, so I am a bit startled as to what could be happening. This of course stops the slideshow rendering.

redndahead’s picture

Status: Needs work » Needs review
FileSize
287.42 KB
61.39 KB

Some fixes.

  • Slideshow doesn't load unless cache is cleared.
  • Views Slideshow Cycle: Pause on hover should be fixed.
redndahead’s picture

Status: Needs review » Fixed

This has been committed.

snufkin’s picture

Could you also commit the views_slideshow.js please?

redndahead’s picture

it's soo done

Status: Fixed » Closed (fixed)

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