我试图检索URL和标题一个值链接字段中的Drupal 8.
在我的自定义控制器中,我检索节点:
$storage = \Drupal::entityManager()->getStorage('node');
$nids = $storage->getQuery()
->condition('type', 'partners')
->condition('status', 1)
->execute();
$partners = $storage->loadMultiple($nids);
Run Code Online (Sandbox Code Playgroud)
当我循环遍历所有节点时,为了预处理变量,我将提供给我的视图,我想检索URL和标题.
foreach ($partners as $key => $partner) {
$variables['partners'][] = array(
'image' => $partner->field_logo->entity->url(),
'url' => $partner->field_link->value, // Can't retrieve values of link field
);
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,我没有找到如何检索URL和标题的FIELD_LINK.
谢谢你的帮助.
在drupal 8的module.routing.yml文件中,函数“node.view”在哪里
_entity_access: 'node.view'
来源:https : //api.drupal.org/api/drupal/core!modules!book!book.routing.yml/8
提前谢谢你
我试图在每一页上附加一个树枝模板。
在 Drupal 7 中,我们基本上使用hook_page_alter
function hook_page_alter(&$page) {
$page['page_bottom']['devel']= array(
'#type' => 'markup',
'#markup' => '<div style="clear:both;">' . theme('TEST') . '</div>',
); // add test template on every page at bottom position.
}
Run Code Online (Sandbox Code Playgroud)
但hook_page_alter
我认为在 Drupal 8 中没有。
如何在 drupal 8 中做到这一点?