0

I have 2 views blocks with the same filter criteria. Both are displayed in different regions on 1 page. But they should not display the same results.

Is there a solution for that?

Note: The views have the same data. But they are sorted randomly.

2
0

There are a few solutions:

  1. You can use Panels module to build your page. Using this module you can insert a block in multiple times.

  2. You can use this code into different regions to display the view

    <?php print views_embed_view("VIEW_NAME","MACHINE_NAME","ARGUMENTS");
    

    The views_embed_view displays the view.

  3. You can also load the block itself despite of what entity has generated it's content by the following code

    <?php
      $block = module_invoke('module_name', 'block_view', 'block_delta');
      print render($block['content']);
    ?>  
    

The How to insert a block into a node or template in Drupal 7? gives you more details about the arguments of above code.

1
  • I'm on holidays right now and will give it a try when I'm back.
    – deelite
    Jul 14 '15 at 6:06
0

Assumption

I'm assuming that the total number of rows returned by the view is at least twice the number of rows you display in each view. If not there is no correct solution possible to your question. E.g.: if you display 5 rows in each block, you must have at least 10 results (total number) ...

Approach

Sort the view in the 1st block on "some column", say ascending (alternative: descending). And sort the view in the 2nd block on "the same column", say descending (alternative: ascending). In case you don't want the selected column to be shown in your block, just "hide it from the display".

Pick a column

Probably a good (best?) fit could be the column you already used for that "random sorting" (you didn't mention yet HOW you implemented that sorting ...). If you don't have such column yet, check if any of the existing fields available in your view can be used for it (such as a node Id or something similar).

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.