By editor , 6 December, 2015 Create a module setting page link on Drupal 8 Tags Drupal 8 Code Module name : simple_analyse
By editor , 5 December, 2015 Create a custom permission in Drupal 8 Tags Drupal 8 Code Permission Drupal 9 Example with a module 'mymodule' Step 1. Create if not exist yet, mymodule.permissions.yml (root of mymodule) Add your new permission like:
By editor , 5 December, 2015 Update a node / Entity programmatically in Drupal 8 Tags Drupal 8 Code Node Update a node: Example 1 : Update title $node = \Drupal\node\Entity\Node::load($nid); $node->setTitle('The new Title') $node->save();
By editor , 4 December, 2015 Create a node With date field Tags Drupal 8 Code Node It is same as normal node creation but must be in format "Y-m-d" (YYYY-MM-DD) Example:
By editor , 3 December, 2015 Use arguments and parameters in url routes Tags Drupal 8 Code Exemple 1 : Form with Node in routing.yml my.node.info: path: '/user/contactmail/{node}' defaults: _form: '\Drupal\myx_meet\Form\ContactUserForm' _title: 'Contact' requirements:
By editor , 2 December, 2015 Get field value of a Node / Entity Tags Drupal 8 Code Node Methode 1 : Example: $value = $node->get($field)->value; $target = $node->get($field)->target_id; // For entity ref Methode 2 Example:
By editor , 2 December, 2015 Get node from url Tags Drupal 8 Code Node Example: $node = \Drupal::routeMatch()->getParameter('node'); if ($node) { $nid = $node->id(); }
By editor , 2 December, 2015 Get the current user in drupal 8 Tags Drupal 8 User Code Example: //use Drupal\user\Entity\User; $userCurrent = \Drupal::currentUser(); $user = \Drupal\user\Entity\User::load($userCurrent->id()); $name = $user->getUsername();