One of the things we'll need for #539682: Replace hard-coded release download table with a view once we have packaged install profile releases with 3 (or more) files per release node is a way to limit and sort the files displayed by this field handler. I've got a patch working, stay tuned...

Eventually, we might want to add a {project_release_file}.weight column for this, but for now, sorting by fid, filename, filesize, or timestamp should work for 95% of the cases.

Comments

dww’s picture

Status: Active » Needs review
StatusFileSize
new17.85 KB
new3.62 KB

I'm not 100% this is the most elegant place to enforce the limit, but it works great for me. Inside pre_render(), as we're building up our array of $items, we just check if we've already reached the limit for any given nid, and if so, we skip that result. Patch for the code, and also a .png of the views UI when you're configuring this field.

dww’s picture

Status: Needs review » Fixed

Committed to HEAD. If there's a cleaner way to do this, I can always change it later. ;)

dww’s picture

From IRC:

[12:40pm] merlin-laptop: dww: Yeah, that looks pretty normal for pre_render() which sometimes is forced to do some fairly direct queries.
[12:40pm] dww: merlin-laptop: the specific question was about enforcing this count limit...
[12:40pm] dww: e.g. I only want at most 2 files per release...
[12:40pm] dww: e.g. this little hunk:
[12:40pm] dww: +        // Enforce the maximum # of files per node as configured in the field.
[12:40pm] dww: +        if (!empty($this->options['max_files']) && !empty($this->items[$file['nid']]) && (count($this->items[$file['nid']]) >= $this->options['max_files'])) {
[12:40pm] dww: +          continue;
[12:40pm] dww: +        }
[12:41pm] merlin-laptop: dww: Seems reasonable to me. Limiting X per Y is always hard.
[12:41pm] dww: ok, great.

Phew. ;) "fixed" it is...

Status: Fixed » Closed (fixed)
Issue tags: -packaged install profiles

Automatically closed -- issue fixed for 2 weeks with no activity.