0

Hopefully someone can help.

I am using a file field and allowing unlimited files within a single content type field called "Video", handled by Media Module. I have created a view per "gallery" of multiple files inside the node, it's already set-up contextually using the nid. Paginating the media files list from this one node result isn't easy to do with what is out there. I have tried infinite scroll but it didn't work out, i have also tried CCK Pager with no luck and the limit settings available are just that limits which don't paginate. Any ideas?

Just to be clear i am not trying to paginate a view of nodes, its a view of files found within a single node.

I am using Drupal 7.63

0

There are two obvious ways to solve this, the easier one is through your existing Content views, and the other is through creating a new File type view.

Content type Views

It is true that the Views type determines what will go into each new row in views results, and Pager is acting on views rows.

But if you have a multi-value field it is possible to make it display each value in a separate views row, making the same node appear many times in the views results, as many times as there are field values.

Here's how you do it:

  1. Edit your "Videos" field and under Multiple field settings make sure you don't have the Display all values in the same row option enabled.

This will make the same node repeat as many times as you have videos, and although the Pager will still work on node rows, it will look like it's working on field values (if you're only showing that one field and not revealing the node Title, for example).

File type Views

To get the Pager to actually page through individual files you have to create File views. There are some steps how you can make that views pull data from one content type and field:

  1. The File views starts by displaying file names of all the files on the system. To make it aware of where the file is being used (you want only the Videos) add a Relationship File: Content using Videos and make it required. This will filter out only the files that are in the "Videos field", and it will make available various Content related Fields and Filters.
  2. Add the "Content: Videos" Field and set it so it doesn't display all values in the same row. You will still see the files repeated in the results.
  3. Don't add any File Fields
  4. Under Query settings enable Distinct and Pure distinct. This will make each file display only once.
  5. Add the Contectual filter for NID, it will be available because of the Relationship you added and it will use it by default.
| improve this answer | |
  • Hi Prkos, Thank you so much... lifesaver. I'm currently implementing your Content type Views approach and it's working like a charm. In order to allow for a node description to come through at the top of the view list i'm using drupal.org/project/views_block_area to allow the fields i need to appear once on the views page... haven't got this to work as yet, need the block to receive the nid to be able to display the description. – Mark P Feb 11 '19 at 11:28
  • Ok, I did not need the "views_block_area" module, instead, the default 'Global: View area' inside the view "header" worked. I created a separate views block which contextually only displayed the node description based on the nid, saved this. I then went back to my views page and added the 'Global: View area' inside the header. IN the settings I selected the 'block view with description' from the drop down, checked the box "Inherit contextual filters" and applied. The description was generated in the first listed position, this can be themed to behave as needed. – Mark P Feb 11 '19 at 18:28
  • Yes, that's the way to do that, you seem to have Views covered :) I haven't tried this but I'm wondering if you could have added the Description as a Field and then Grouped under Format, but I expect that would still mess up Pager. – prkos Feb 11 '19 at 19:04
  • 1
    I did add the Description as a Field to see what would happen but the default result was the description was shown multiple times, as you suggested. I'll try out the Grouped idea but the 'Global:View area' worked well and find it intuitive and far more adaptable to different needs, i imagine. The more i delve into Drupal the more powerful it seems to be. – Mark P Feb 11 '19 at 20:34

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.