Currently all slides are loaded at once during page load, this works well enough for the display of popular lists or new content lists where you may only need a handful of slides. However, if ajax loading was used, it would allow a block to continually and elegantly feature random site content.

Would it be reasonable to have this functionality included at some point?

Thanks for reading.

Comments

ppblaauw’s picture

Thanks for reporting.

To allow the dynamic display block module to display larger amount of slides, AJAX loading of new slides would be necessary.
This would be a nice feature to add to the dynamic display block module and we will try to implement this in the future.

Any help appreciated.

highvoltage’s picture

Thanks ppblaauw, I always appreciate your quick responses. Looking forward to this functionality. ^_^

gunzip’s picture

subscribe.

EDIT:
actually views support ajax loading. it's possible to obtain ajax loading of slides using the views2 pager
(ie. setting only 1 item to appear in the block). it would be nice to integrate this with ddblock to use
its styling etc.

asak’s picture

+1

ppblaauw’s picture

@gunzip, asak.

Any idea how to implement this in the ddblock module.
Any help appreciated.

I am first trying to implement ajax loading for the basic slideshow with images from a folder.
Will tomorrow post the code here I have till now.

gunzip’s picture

i think that it should be enough to use the views2 handle of ajax and just implement a custom pager (tpl) with something like this inside:

<ul><li class="pager-previous last">' . theme_pager_previous('<<', 1) .'</li></ul>
<ul><li class="pager-next last">' . theme_pager_next('>>', 1) .'</li></ul>

so the pager links are already computed by the view. just set the view to show only one item into the block.
i hope this is doable without touching the module code...

ppblaauw’s picture

@ gunzip

Could you give some more details about your solution.

I can not see how this would get additional slides with AJAX after loading at least 2 initial slides which is required by the jQuery cycle plugin to work.

highvoltage’s picture

I think what he may mean is to use the already existing views pagination to switch slides. Create a view with random sorting and ajax paging, set the page to one, and then have DDblock initiate a 'next page' action. Let views pagination handle the slide switching, and just add in the visual effects/overlays, etc etc. Using views for pagination, wouldnt require loading two initial slide would it?... Anyway, I'm not a programmer so what I'm saying might be totally ignorant and useless, but i think that's the basic idea of the suggestion.

gunzip’s picture

@highvoltage: right

maybe it's possible to use the 'after'/'before' properties of jquery cycle plugin to load the next slide from the view (it can be done even triggering the click event on the view pager link) before the animation. i'll look into this asak.

asak’s picture

@gunzip: Sending you some good karma for this one... ;)

ppblaauw’s picture

To inform you all:

What I am trying out now is using the onbefore function of the jcycle plugin, but still have some issues which I posted on the jQuery list.

  function onBefore(curr, next, opts, fwd) {
    // on Before arguments:
    //  curr == DOM element for the slide that is currently being displayed
    //  next == DOM element for the slide that is about to be displayed
    //  opts == slideshow options
    //  fwd  == true if cycling forward, false if cycling backward

    
    //Slide html creation helper.
    function ddblockGetSlideHTML(slideImg) {
      return '<img src="' + slideImg + '" width="200" height="200" alt=""/>';
    };

    opts.ajaxLoadSlides = 1; // Will be set later from UI
    opts.totalSlideCount = 6; //Will be set later from UI
    //load slides dynamically
    if (opts.ajaxLoadSlides) {
    
      // on the first pass, addSlide is undefined (plugin hasn't yet created the fn); 
      // when we're finshed adding slides we'll null it out again 
      if (!opts.addSlide){
        return;
      }
        
      if (opts.nextSlide + 1 == opts.totalSlideCount) {
        // final slide in our slide slideshow is about to be displayed
        // so there are no more to fetch
        alert('last slide to be dislayed, nothing to add anymore');
        opts.addSlide = null;
        return;
      }

      // Retrieve slide from server via AJAX, call; if successful the
      // anonymous function in voteSaved is run.
      $.ajax({
        type: 'POST', // Use the POST method.
        url: 'get_image_slides',
        dataType: 'json',
        data: {js:true,origin:'ddblock',curr_slide:opts.currSlide,next_slide:opts.nextSlide,delta:opts.ddblocknr},
        success: function(data) {
          // add our next slide
          opts.addSlide(ddblockGetSlideHTML(data.slideImg), fwd == true);
        },
        error: function(xhr) {
          //alert('Error: ' + xhr.status + ' ' + xhr.statusText);
        }
      });
    }
  }

I first have 2 initial images
after that, images are loaded with AJAX
The ajax call returns the image ok
The problem is that opts.currSlide and opts.Nextslide give strange values so the wrong images are selected.
When I look in FF console the post values for currSlide and nextSlide are.

0 - 1
2 - 1
2 - 3
4 - 1
2 - 3
4 - 5

I get the images in the PHP script on nextSlide +2
So i expect :
0 - 1 -> get image 3
1 - 2 -> get image 4
2 - 3 -> get image 5
3 - 4 -> get image 6

Another problem is I use slideExpr to select the right content to slide.
How can I you use addslide to add slides to the SlideExpr.parent

These are the issues I have, otherwise working.

Will later add this for advanced slideshow. After I get this working it will not be that difficult.

ppblaauw’s picture

To inform you all:

Ajax loading of slides is working now on our testserver for the basic slideshow option of the dynamic display block module.

Will try to implement it now for the advanced slideshow option.

When this is finished and the documentation is updated will release a new version of the dynamic display block module.

asak’s picture

@ppblaauw: you're amazing... ;)

highvoltage’s picture

No kidding, great job. I was dying for ajax loading. This is highly appreciated. (b^_^)b

happydrupal’s picture

Awesome.........

joostvdl’s picture

Subscribing

Please let us know when it is available. This is a great new feature!

vacilando’s picture

Issue tags: +Ajax

Wow! Subscribing!

dddave’s picture

Make this great module even greater!

doublejosh’s picture

subscribing.

next... AJAX loading/refresh to get content created after the page was initially loaded. I know there is a way to trigger an AJAX view to refresh.

ppblaauw’s picture

@doublejosh,

Thanks for your interest in the dynamic display block module.

The Ajax loading of slides is working with the module, but I am restructuring the module so more output side plugins can easily be added to the module. After this is finished I will release a next version of the module.

(I can not spend so much time on development at the moment.)

If you have suggestions for loading slides after initial page view please let me know.

mrfelton’s picture

subscribing. So, is this functionality is in CVS?

ppblaauw’s picture

#21, no it's not published.

TimG1’s picture

+1 and subscribing!

I wish I could offer more help on the programming side of things, but lack those skills. But, a similar module out there uses ajax loading. www.drupal.org/project/quicktabs . Maybe there is some way to use what that project has done?

ibis’s picture

subscribing