• A list of Drupal problems with solutions
  • Random Drupal Stuff

Drupal 8: views_query_alter - setLimit()

Submitted by Calvin on Fri, 04/19/2019 - 12:16

If you need change the limit of a views query dynamically it would seem obvious to use:

$query->setOffset($offset);
$query->setLimit($limit);

However, the pager overrides this.

To make this work use the following:

$view->setOffset($offset);
$view->getPager()->setItemsPerPage($limit);

Note these methods are on the $view object and not the $query object.

Sane Drupal Perms

Submitted by Calvin on Tue, 02/16/2016 - 15:53

Stop treating roles as people. Treat them as responsibilities. Lots of people can be 'Content Editors', some can be 'Content Publishers', others 'Views Editors'. This idea is simple but powerful. Rather that trying to define a person's job in a role, create many small, single-purpose roles and then compose them together by giving many roles to your users to achieve your goals.

http://atendesigngroup.com/blog/drupal-permissions-done-right

BEM - Component Focused Dev + Owls!

Submitted by Calvin on Fri, 09/11/2015 - 14:18

Just a some bookmarks to a couple things that complement each other for front end dev.

http://www.joelambert.co.uk/articles/bem-guidelines

Great article about BEM guidelines for component focused development.  The section about margins and the template layout reminded me of this:

http://alistapart.com/article/axiomatic-css-and-lobotomized-owls