hi all.
i've been looking a lot for this, web an ds api, but i was not able to find a way.

is it possible to alter the format limit setting of a multiple-values field?
also, i'd like to alter it at runtime, limiting the number of items per role and, since this is a pretty project-specific thing, a little alter would be great.

i know there are other ways to achieve this, but they all are worse.
is this possible somehow or formatters get cached in such a way that it's just not possibile?

thanks a lot.

Comments

aspilicious’s picture

Status: Active » Closed (won't fix)

Not easily possible and not a ds feature

sgurlt’s picture

Status: Closed (won't fix) » Closed (works as designed)

Not so complicated at all, just implement the following in your custom module and make sure that it gets executed after ds:

function my_custom_module_field_attach_view_alter(&$build, $context) {
  $field = 'field_my_field';
  if (isset($build[$field])) {
    $limt = 3;
    $build[$field]['#items'] = array_slice($build[$field]['#items'], 0, $limit);
  }
}
aspilicious’s picture

Woow, thank you sg88.
Makes 100% sense :)