In Drupal theme provide the design for the pages and contents. We can use multiple themes for our website. Using the user role, permission and page URLs we can able to change the theme. This is the simple example of implementing theme per page by URL.
To create a node which has a paragraph field you must create a Paragraph Item and respective object has to be referenced to the field. If this is a multiple add more field you can just loop this with the appendItem() for multiple items.
The following code will return the root path for a drupal file system. \Drupal::service('file_system')->realpath(file_default_scheme() . "://") . '/');
To enable revision and to log revision message on saving a node in drupal 8 we can use setNewRevision() and setRevisionLogMessage(). Find the below code which uses entity save with revision.
In MySQL, the ORDER BY keyword is used for sorting the records ascending(ASC) or descending(DESC), by default it will be on ascending. The default ORDER BY statement will not work with Alpha-Numerical values(The values is mixed of both numbers and strings). To resolve this problem we can use ABS() MySQL function.
To load the author name or owner from a node entity object we can use getOwner(). The below example show how to load a node object using node id and to get the Author name from it.
Getting the content type using a node id in drupal 8 can be achieved using bundle() function. The following code will return the node object.
The following code will return all the available fields as an array by a field type. You can pass the field type that you want to load within getFieldMapByFieldType() function.
The below code will return all the available user roles as an array in drupal 8.
Changing the location of the module which is installed will return error. To do this you have to rebuild the APC cache. Try the one of the following steps after changing the module location.