小编Rah*_*eth的帖子

如何以编程方式获取Drupal 8中的内容类型名称

我正在研究Drupal 8.我希望获得内容类型的机器名称和标签.这是我的代码:

$cont_type = node_type_get_types();
foreach ($cont_type as $key => $value) {
  $label = $value->name;
  $machine_name = $key;
}
Run Code Online (Sandbox Code Playgroud)

这里我收到一条错误消息: Cannot access protected property Drupal\node\Entity\NodeType::$name

content-type drupal-8

7
推荐指数
4
解决办法
1万
查看次数

标签 统计

content-type ×1

drupal-8 ×1