Skip to main content

Drupal 8 Node Operations

Submitted by system on
Check if field exists in a node <?php $entity->hasField('abc'); ?> Get value of a field: <?php use Drupal\node\Entity\Node $title = Node::load($nid)->get('title')->value; $node = \Drupal::entityManager()->getStorage('node')->load($nid); //Another way to load ?> For User Added fields: <?php $terms = $node->get('abc')->getValue(); $terms = $node->abc->getValue(); ?> Get Nid from URL <?php $nid = \Drupal::routeMatch()->getRawParameter($node_id); ?> -- Link https://www.frobiovox.com/posts/2016/03/28/simplify-drupal-8-field-value-calls.ht

Server Certification

Submitted by system on
Checking Passphrase for private key:
openssl rsa -check -in keyfilename
Changing Passphrase:
openssl rsa -des3 -in keyfilename -out newkeyfilename
Installing or trusting certificates: Extensions .crt, .pem and .cer are interchangeable, just change the file name extension, they have the same form. Try this: sudo cp mycert.cer /usr/share/ca-certificates/mycert.pem
sudo dpkg-reconfigure ca-certificates
sudo update-ca-certificates

Drupal 8 Theming

Submitted by system on
Templates are the default option for hook_theme: https://www.drupal.org/node/2231673 Advanced Theme Settings Change Record: https://www.drupal.org/node/2382645 Drupal 8 theming guide: https://www.drupal.org/theme-guide/8

API changes in Drupal 8 in comparison to Drupal 7

Submitted by system on
This post would reflect on few essential APIs in Drupal 7 and how they were changed in Drupal 8: drupal_get_title()
: Gets the title of the current page. Link to changelog here . Drupal 7: <?php $title = drupal_get_title(); ?> Drupal 8: <?php $request = \Drupal::request(); $route_match = \Drupal::routeMatch(); $title = \Drupal::service('title_resolver')->getTitle($request, $route_match->getRouteObject()); ?> -- Links: https://www.drupal.org/node/2067859

Opcache with Drupal

Submitted by system on
OPcache is an opcode cache for PHP. It is bundled with PHP 5.5.0 and later. The following settings work really well with Drupal. For Ubunti 14.04 , these following file can be modified to incorporate the changes /etc/php5/apache2/php.ini
Configuration: opcache.enable=1
opcache.memory_consumption=256
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1