dth42345
2018-08-10 13:43
浏览 138
已采纳

以编程方式从drupal 8获取所有节点

I am trying to get all nodes of a certian type from drupal. I have tried many ways to achieve that, but maybe due to my lack of Drupal custom module programming experience I couldn't achieve my desire. the closest way that I found on the web, is this:

    $nids = \Drupal::entityQuery('node')->condition('type','news')->execute();
    $nodes =  \Drupal
ode\Entity\Node::loadMultiple($nids); 
  • the first line returns an object of id's
  • the second line returns the nodes of those id's

this looks easy and straight forward. but, this is the output! { "59": { "in_preview": null }, "61": { "in_preview": null } }

can someone please help, what is wrong? and is this the correct way to do it ?

I want to take the nodes then search every one of them ( I am making some sort of search engine) so I expect some kind of an object that I can then extract the heading, body ... etc, from. is this the correct way ?

图片转代码服务由CSDN问答提供 功能建议

我试图从drupal获取certian类型的所有节点。 我已经尝试了很多方法来实现这一点,但也许是由于我缺乏Drupal自定义模块编程经验,我无法达到我的愿望。 我在网上找到的最接近的方式是:</ p>

  $ nids = \ Drupal :: entityQuery('node') - &gt; condition('type','news') - &gt; execute(); 
 $ nodes = \ Drupal 
ode  \实体\节点:: loadMultiple($ NIDS);  
 </ code> </ pre> 
 
 
  • 第一行返回id的对象</ li>
  • 第二行返回那些id的节点</ li> </ ul>

    这看起来简单直接。 但是,这是输出! { “59”:{ “in_preview”:null }, “61”:{ “in_preview”:null } } </ code> </ p>

    有人可以帮忙,有什么不对吗? 这是正确的方法吗?</ p>

    我想接受节点然后搜索它们中的每一个(我正在制作某种搜索引擎)所以我希望某种形式的 然后我可以从中提取标题,正文...等对象。 这是正确的方法吗? </ p> </ div>

1条回答 默认 最新

相关推荐 更多相似问题