Use cases:
1. a What's News page where the first few items are displayed differently from the rest. For example, the first few items could be node teasers and the rest just a list of title field.
2. a Picture gallery page where the first few items are made into a slideshow (e.g. by views_slideshow)

At first I thought the "Attachment display" could be used for something like this and it seemed to work. However, once a pager was used and the pager was on page 2, the output of the Attachment display were out of sync with the Page display because the number of "Items to display" were different in both display. So, it seems an Attachment display has its own set of query results instead of using the query results from the main display.

How should the mentioned use cases be done in Views? If not possible, perhaps a "Style display", a display that get attached to and always use query results from the main display, would be a great addition to Views.

Comments

dawehner’s picture

Attachments is definitive the way to go.

But i guess you need a way do hide the attachment on page > 0

esmerel’s picture

Status: Active » Postponed
alanom’s picture

[EDIT: next post has a working workaround!]

So what's the latest on this? I'm also encountering this problem (and I believe so too is this guy - http://drupal.org/node/1049692) - I'm surprised that there seems to be no solution.

My use case: A 'news archive' page with two columns. Column A is this page's top news story in full, column B is the next 8 news stories with teasers and thumbnails, and there's some jquery/bbq trickery to update column A with selected stories.

Expected result: page 1 shows story 1 in full and 2-9 in teaser. Page 2 shows story 10 in full and 11-20 in teaser. Repeat.

Actual result: page 1 shows story 1 in full and 2-9 in teaser. Page 2 shows story 2 in full and 10-18 in teaser.

This is clearly a known common issue to the point that there's a mysterious warning, "Note that this [pager inheritance] will provide unexpected results if the number of items to display do not match". So, what's the standard fix, and until when is this postponed - does 'postponed' here mean "Won't fix in Views 2, will fix in Views 3"?

Re. Dereine's suggestion, that would probably work in my case but only because this archive's a low-priority feature so it doesn't matter if there's a big empty space on pages 2+. I'm going to experiment with some possible workarounds using Customfield module and I'll post if I find one that works, but it'd be good to get a proper solution that doesn't require phpfields and such.

alanom’s picture

Okay, here's a workaround that works. This is for the original task, to get the 'expected result' where the attachment pages with everything else. It could probably be adapted to do Dereine's method, but you'd need to find out how to pipe paging data into a phpfield.

Strengths of this method:

- It works
- It requires no manual hacking and no changes to files

Weaknesses of this method:

- It requires the module Views Customfield and the php fields this enables - http://drupal.org/project/views_customfield
- It needs some (easy) maths
- It's inelegant, but unlikely to cause any performance issues unless your view is searching on the world's craziest database. Your server will do a small amount of unnecessary work (the attachment will process the fields that are already being loaded in the main display), but your site visitors will download no unnecessary HTML. In a normal case the difference will be barely noticeable, and there'll be no difference at all if it's cached

1) Install views_customfield etc etc, make sure phpfields are enabled and that you've got permission to use them.
2) Combine all your views' display fields into one field. Normally this means setting them all to 'Exclude from display', then adding a 'global: custom text' field, then filling it with Replacement Patterns. (if this sounds new to you, it's quite common practice)
3) Set this to 'exclude from display' as well
4) Create a customfield: php field, copy in the following code:

<?php 
// increases by 1 with each row
$static++;
// EDIT THESE VALUES to match your ideal attachment settings
$offset = 1;
$items_per_page = 8;
$desired_items_per_attachment = 1;

// the un-googleable % below means 'modulus', i.e. 'remainder after dividing left by right' 
if (( $static + $offset + $items_per_page ) % ($offset + $items_per_page + $desired_items_per_attachment) == 0) {

// EDIT THIS replacing [nothing] with the Replacement Pattern of your combined field
 print "[nothing]";

} else {
// do nothing
}
?>

5) Edit the parts marked 'EDIT' in the code
6) Set the attachment's Items Per Page to match the main view's Items Per Page

This will make the attachment follow the paging of the main view.

merlinofchaos’s picture

Status: Postponed » Closed (won't fix)

The workaround will have to do; it's difficult if not impossible for Views to use multiple row styles in the same view.