New answers tagged

0

The error is about accessing field_dark_theme from an un-existing node instance. The proper way of loading the node during preview is explained here. On the other hand, welcome to the wonderful world of PHP for debugging properly (on Drupal), please check this post and this documentation entry check your proper IDE/stack on how to setup debugging tools.


1

In /admin/people/permissions Under "Node" category you can uncheck the permission "Edit content X" for your desired role. I would recommend using this module if your site has a lot of modules/permissions since due max upload vars limitation by PHP could led to not storing your chages when submitting the form. Also by code you can implement ...


1

The text of the submit button depends only on the translation settings of the status field. If the field "Publishing status" is not translatable for the content type, the button says "Save (all translations)". You can change the language settings for content types, taxonomy vocabularies, user profiles here: /admin/config/regional/content-language


2

You should use hook_node_presave if you want to change a field's value as the hook is invoked from node_save() before the node is saved to the database. And as leymannx stated, make sure you clear the cache before implementing a new hook.


0

The problem was that the Body field was not added to the DrupalGap Display Mode for the content type: By default, there are no fields displayed using the DrupalGap Display Mode. We need to specifiy which fields, labels and formats will be used when our nodes are displayed in the mobile app. Do this for each content type.


2

How todo it custom in code such as in a hook_form_alter $form['something'] = [ "#title" => t('@title', ['@title' => 'My Title'), "#type" => "details", "#group" => "advanced", "#weight" => 50, ]; // Add fields to the group. $form['something']['text'] = [ "#title" => t('@title', ['@title' => 'test'), "#type" => "textfield",...


2

The latest version of Field Group module supports putting fields into the sidebar (at least for nodes). Field Group version >= 3.0-rc2, containing issue 2652642


0

This is a Durpal 7 Problem. It lies about that it will fall back to 0/1 if you don't provide your custom true/false values, when it actually does not fall back. See https://www.drupal.org/project/drupal/issues/1750950 In short, in the field-settings, you have to set on-/off- values. If you don't the default renderer will output an empty string and in the ...


2

That's a task for the Features module. Before Drupal 8 and its superb configuration management the Features module was used to track and deploy changes to entities or settings from local to prod or to your coworkers. Nowadays you can use it to track changes and sync features across multiple instances of Drupal. Let's say you have two Drupal 8 sites or two ...


1

You can view the item at /node/{node_id}. If you need the item in a view, you can add a filter to the view for the node's id.


0

To create a custom rest resource: Enable rest module: drush en rest -y Create the plugin like the following YOURMODULENAME/src/Plugin/rest/resource/RegionNodeRestResource.php: namespace Drupal\YOURMODULENAME\Plugin\rest\resource; use Drupal\rest\ModifiedResourceResponse; use Drupal\rest\Plugin\ResourceBase; use Symfony\Component\DependencyInjection\...


1

If you need to alter the value of a node field right after the node has been created, you don't need that code. You just need to implement hook_ENTITY_TYPE_presave() and verify the node is new. function mymodule_node_presave(EntityInterface $entity) { if ($entity->isNew()) { // The node has been created. // Access the node field using $entity. ...


1

For the comment count you can get it in the node twig by: {{ content.comment['#items'].comment_count }} But the flag count i think there is no way to get it directly in the twig: There is extension called flagcount in the flag module but it requires the flag object which is not available in node twig. From comment section of flagcount callback function in ...


Top 50 recent answers are included