2

I am trying to insert a SimpleAds block for each page of a View. But pages are loaded via AJAX using infinite pager. How can I insert a SimpleAds block into each dynamically loaded page of results?

5
+50

You want to add a javascript such one below to either your custom module or theme (would recommend module). This will react on a view that has a class view-infinitestack, so replace it to match yours view.

Where the debugging code is (console.log) you can add whatever JQuery you need. Eg. ajax call to fetch new content and inject it in another div, sidebar, or anywhere else on the page just by using JQuery, etc...

(function($) {
  Drupal.behaviors.events = {
    attach: function(context, settings) {
      $('.view-infinitestack', context).ajaxSuccess(function(){
        // add your js here to refresh a block
        console.log('success');
      });
    }
  };
})(jQuery);
1

Checkout the block refresh module

As the name implies, Block Refresh allows an administrator to configure a block to refresh it's content in a given number of seconds. Block Refresh uses jQuery/AJAX so the refresh happens "behind-the-scenes".

Current Features:

  • Automatically refresh a block in a set number of seconds (configurable per block)
  • Allow site visitor to manually refresh block (configurable per block)
0

If they have a common path, you can simply create a Block and tell it to only appear when the path matches. So for example, if your path was something like 'ads/[date]/[title]'.

In your block, tell it to only appear for ads/*. That should achieve what your looking for.

0

It could be done using the tpl files.
Check the theme information you will find a common tpl file name place that block in "Display output" or "style output".

Its not the best way to do it, but you can do it in this way. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.