New answers tagged nodes
-2
votes
How can I programmatically save node components?
$entity = \Drupal::entityTypeManager()->getStorage('cohesion_layout')->load($node->get('field_layout_canvas')->getValue()[0]['target_id']);
$layoutCanvas = $entity->...
0
votes
How to programmatically add content to a group in the Group Module?
Once installed the type of relationship in the group with the code feels should be sufficient for Drupal 8, 9, 10.
$node = Node::create([
'type' => 'node_type',
'title' => 'My title',
'uid'...
1
vote
How to restrict access to some nodes based on roles or users?
This is a few years old but I thought I would throw in an answer on how to do this with a very light weight custom module. This answer would be applicable to Drupal 8, 9, and 10.
I am using Drupal 8 ...
0
votes
How to programmatically set a node field as empty?
For Drupal 8 and above:
$entity->set('body', []);
$entity->save();
Top 50 recent answers are included
Related Tags
nodes × 75377 × 2395
entities × 1132
views × 1044
8 × 859
theming × 725
users × 544
taxonomy-terms × 412
forms × 396
hooks × 288
6 × 284
media × 228
database × 211
rules × 192
blocks × 184
files × 146
javascript × 119
routes × 119
navigation × 117
i18n-l10n × 108
ajax × 105
9 × 98
comments × 96
webforms × 93
importing-exporting × 88