Answer the question
In order to leave comments, you need to log in
How to translate individual nodes on one page?
Good afternoon. There was a question, the following content: several blocks are displayed on the page. A material type has been created for each. The site is multilingual. Those. in the admin panel, you can translate any of the nodes.
These blocks are output like this:
namespace Drupal\text_imgs\Plugin\Block;
use Drupal\Core\Block\BlockBase;
class TextImgsBlock extends BlockBase
{
public function build()
{
$query = \Drupal::entityQuery('node')
->condition('type', 'text_imgs')
->condition('status', NODE_PUBLISHED)
->sort('field_sort', 'ASC')
->range(0,6);
$nodeIds = $query->execute();
$items = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($nodeIds);
return array(
'#theme' => 'text-imgs',
'#data' => array(
'items' => $items
),
);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question