【问题标题】:Query Paragraph Type in Drupal 8Drupal 8 中的查询段落类型
【发布时间】:2019-03-01 18:30:41
【问题描述】:

我正在尝试查询某种类型的所有段落,但没有得到任何输出。我的查询对吗?当前返回一个空数组。

$query = $this->node->getQuery()
          ->condition('type', 'my_paragraph_type')
          ->execute();
        $this->logger->info('query: ' . json_encode($query));

【问题讨论】:

  • 你能解释一下 $this 代表什么类的实例吗?我只是好奇,你从哪里得到这个代码? :)
  • 抱歉劫持这篇文章一秒钟 - @j-e - 在你得到答案后删除你的 question 在 SO 上不是很好的做法。如果您重新考虑您对此的决定并取消删除它 - 我将有机会向您解释为什么我的回答对您有所帮助

标签: drupal drupal-8 drupal-entities


【解决方案1】:

尝试使用 entityQuery('entity_type')

$pids = \Drupal::entityQuery('paragraph')
  ->condition('type', 'my_paragraph_type')
  ->execute();

【讨论】:

    猜你喜欢
    • 2018-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多