New answers tagged

1

Posting a link to the d.o issue queue where as of this week a potential patch to core to allow EntityQuery to recognize Workflow moderation state that @Santiago cited above: https://www.drupal.org/project/drupal/issues/3025164#comment-13221005 Without this patch or a similar core hack, EntityQuery can not query Drupal 8 Workflow moderation state.


0

You could also chunk the array of ids into smaller chunks in order to use less memory and avoid looping once for every single node: $nids = [ // Some big list of nids... ]; $storage = \Drupal::entityTypeManager()->getStorage('node'); foreach (array_chunk($nids, 50) as $chunk) { $nodes = storage->loadMultiple($chunk); storage->delete($nodes); ...


0

To achieve this in views, you have to add a relationship named "Commerce Line item: Referenced products" and it will fetch field from your product node.


0

Just tried it out myself and for me it didn't work using your malformatted #attributes array. After I fixed it the following did work. class must provide another array. /** * Implements hook_ENTITY_TYPE_view(). */ function MYMODULE_node_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\...


0

As an option you can index the entire rendered HTML of your content. Let's assume your index is called "default_node_index" and content type is "article". Visit /admin/config/search/search_api/index/default_node_index/workflow Enable "Complete entity view" Visit /admin/config/search/search_api/index/default_node_index/fields Enable "Entity HTML output". ...


2

Is this the correct way to query for nodes that contain a particular taxonomy type field? \Drupal::entityQuery() is the correct approach, yes. How do I filter for nodes that contain a specific taxonomy term? Would you like to filter by the taxonomy term name? If so you need to get the taxonomy term ID and use that in your condition: // Get an array ...


0

I guess Filebrowser module is what you looking for : This module provides an interface for administrators to expose directories on the file system to users through a file listing as in a FTP application. You will create one node (node type dir_listing) for each each Directory Listing (DL). Node settings are used to control access and other features of the ...


0

For drupal 7: $update_node = node_load($nid_to_change); $update_node->changed = $timestamp_in_unix_form; drupal_write_record('node', $update_node, 'nid'); This is very dumb routine; it's bypassing a lot of error checking in node_save(). It expects a complete, intact node. so it's up to you to make sure the node integrity is good. Otherwise you risk ...


1

Drupal 8 For Drupal 8 it would go like following. First add the file and get a file ID. Then create the node and attach the given file ID. $data = file_get_contents(__DIR__ . '/images/my_image.jpeg'); $file = file_save_data($data, 'public://my_image.jpeg'); $node = \Drupal\node\Entity\Node::create([ 'type' => 'page', 'title' =...


5

Do not use the raw field value, use the render array of the field instead: {{ content.field_stories }} This will automatically use the correct language. NOT RECOMMENDED: If you have to go the custom, raw value route you can do something like {% for story in node.field_stories %} {% if story.entity.hasTranslation('iso2_langcode') %} {{ story.entity....


0

Just change your code: $Dfiles = []; foreach ($FilePaths_keys as $path){ .... $Dfiles[] = [ 'target_id' => $file->id(), 'alt' => $item['bitstreams'][$path]['name'], 'title' => $item['bitstreams'][$path]['name'] ]; } $node->set('field_book_image', $Dfiles); $node->enforceIsNew(); $node->save();


0

For Drupal 8 media items (e.g. Remote Video), use getName()


0

Great explanation, what I did was simpler and dirtier by putting in the css display: none. But I should try your suggestion. What I think drupal will be necessary to separate the types of links to be able to use them in different ways in different places. I think the design is for a web design older than how the card links is implemented which is a more ...


Top 50 recent answers are included