-2

I need to create a select with the results of all elements of a particular content-type.

The results of all the elements of said content-type I get them like this:

{{drupal_view ('areas_practicas', 'areas_all')}}

But it generates preformatted results (with HTML in between) (or with the output of the development mode, with reference to the template that uses that sample)

  • 1) Is it possible to return only one array of strings to be able to paint them in the select, without HTML or anything?

  • 2) Is it possible to traverse the results of this block since twig? Something like


{% for area in drupal_view ('areas_practicas', 'areas_all') %}
    {{area.title}}
{% endfor%}

1 Answer 1

0

I would do it like this: first get a set of all needed nodes with a query, and then process the node to create your select

For all published articles of content type 'areas_practicas' for example:

$query = \Drupal::entityQuery('node')
        ->condition('status', 1)
        ->condition('type', 'areas_practicas');
$nids = $query->execute();
foreach ($nids as $node)
{   
    $n = node_load ((int)$node);
    // get title of node and process it
}

I hope this helps, Ruud

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.