简体   繁体   English

如何在内容类型drupal下显示所有内容

[英]How can i display all content under content type drupal

I have a create 2 Content type like 我有一个创建2内容类型

Finance Form 
HR_content_Form

Then NOw including article and page i have 4 content type 然后NOW包括文章和页面我有4种内容类型

Article 
Basic Page
Finance Form 
HR_content_Form

Then i have added content under Finance Form and HR_content_Form.Now i want to display all content under content type so i tried 然后我在Finance Form和HR_content_Form.Now我想要显示内容类型下的所有内容添加内容所以我试过

$types = \Drupal::entityTypeManager()
  ->getStorage('node_type')
  ->loadMultiple();





foreach ($types as $machine_name => $content_type) {
    $label[] = $content_type->label();

  }



echo '<pre>';print_r($label);

Now it display all content type. 现在它显示所有内容类型。 How can i display datas i have added under Finance Form ,HR_content_Form .Please help me 如何显示在Finance Form,HR_content_Form下添加的数据 。请帮助我

You can loadByProperties . 你可以loadByProperties

$types = \Drupal::entityTypeManager()
  ->getStorage('node_type')
  ->loadByProperties(['type' => ['finance_form', 'hr_content_form']]);
SELECT node_field_data.langcode AS node_field_data_langcode, node_field_data.created AS node_field_data_created, node_field_data.nid AS nid
FROM
{node_field_data} node_field_data
WHERE (node_field_data.status = '1') AND (node_field_data.type IN ('finance_form', 'hr_content_form'))
ORDER BY node_field_data_created DESC
LIMIT 11 OFFSET 0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM