Powered by Drupal

Make composer works on Digital Ocean

By Ivan Aldavert on Friday, March 2, 2018 - 19:41

When we try to install/update some stuff with composer, anyway we put -1 memory (or +1000) it still not working, to solve this we can create a swap file.

Here is the trick:

free -m

mkdir -p /var/_swap_

cd /var/_swap_

#Here, 1M * 2000 ~= 2GB of swap memory

dd if=/dev/zero of=swapfile bs=1M count=2000

mkswap swapfile

swapon swapfile chmod 600 swapfile

echo "/var/_swap_/swapfile none swap sw 0 0" >> /etc/fstab

#cat /proc/meminfo

free -m

Drupal 8 views: render entity vs views fields format

By Ivan Aldavert on Friday, March 2, 2018 - 19:35

Using a fresh install of drupal in, let's do these steps:

  • Ensure views is enabled
  • Enable Devel, Devel generate content and Web Profiler
  • Create one view with 2 page displays, one with "render content" and the other with "views fields"



This display uses render entity with Teaser view mod. This mod has body and image fields. Path is /article-render



This display uses views fields, we have to set up field by field, in this case, we add the same fields that teaser view mod has.


Now let's create some articles with Devel Generate Content. yoursite/admin/config/development/generate/content", select article and do generate.


Now we have the content and two view pages, lets check with web-profiler which of those displays is more efficient. Our check is always after cleaning the caches, because the cache reduces the loading time to same.



CASE 1: view with render entity


render time


CASE 2: display with views fields






Without caching the page, the views fields is more efficient because it is doing less queries than render content display. But in a real world, who set up pages without caching?


PS Build pages or blocks of content like list of teasers with view mods give us the opportunity to use the powerful of twig and set up custom html for this pieces of content. Instead, with views field we should manipulate the preprocess of views elements.