Is there any module that adds the ability to use tokens here:

Such that in passing parameters to the block from code I could pass the offset number also? This would allow one view, with 1 item to display, set to distinct, to be called multiple times on the page, each time incrementing the offset to get the next item from the view.

Or am I going about this the wrong way ;D

Accepted answer

I'm not aware of a module that allows you to do this, and I don't really know if you are going the wrong way about this as I don't know what you are trying to display and why ;-)

But overriding the number of items or offset can be done programmatically through YOUR_MODULE_NAME_views_query_alter($view) by using methods set_offset() and set_items_per_page(). See https://drupal.stackexchange.com/questions/185977/alter-views-limit-usin...

Passing a parameter to this hook is a different story and can be a bit complicated. Where is this parameter coming from? Does it depend on the context?

Comments

I'm not aware of a module that allows you to do this, and I don't really know if you are going the wrong way about this as I don't know what you are trying to display and why ;-)

But overriding the number of items or offset can be done programmatically through YOUR_MODULE_NAME_views_query_alter($view) by using methods set_offset() and set_items_per_page(). See https://drupal.stackexchange.com/questions/185977/alter-views-limit-usin...

Passing a parameter to this hook is a different story and can be a bit complicated. Where is this parameter coming from? Does it depend on the context?

The scenario: 

I have a dashboard that shows a 3-column grid where the grid blocks are separated blocks defined by Layout. Within these 3 blocks I am rendering a view, ie MOOA1 ->3, where I am replicating this view once it works, and adjusting the offset so that I get the next in the series of expected results, so MOOA2=Offset 1, MOO3=Offset 2.

The view(s) is set to Pure distinct in order to avoid duplicates of these "Current Openings" you see below, yet I am getting duplication as you can see.

The stepping parameter is currently only locked into the view, but I will check the link you sent to see if I can pass that via the TPL views_embed_view, and therefore reduce the actual number of Views to 1, and send it the stepping.

Thanks.

Sorry to fill the forum with spam...I found the problem was an errant TPL. My system described above works, when the code is correct in the TPL! D'oh.

In case anyone runs into this need, you will find the following code helpful in debugging:

function mymodule_views_query_alter(&$view, &$query) {

if ($view->name == 'my_view_name' && $view->current_display=='v-ew_display_machine_name' ) {

dpm($view->display_handler->options); // dump the display options

}

}

Screenshot shows the pager array for my offset handler on this display, which of course can be modified by:

$view->display_handler->options['pager']['options']['offset']=5; // to set as item number 6(zero-based).