【问题标题】:Namespace issue with Concrete5 Express List on Single Page单页上的 Concrete5 Express 列表的命名空间问题
【发布时间】:2018-08-12 09:41:52
【问题描述】:

我正在尝试按照此链接按照教程来检索快速条目:

https://documentation.concrete5.org/developers/express/creating-read...

但是,我收到以下错误消息:

“找不到类'Application\Controller\SinglePage\Concrete\Core\Express\EntryList'”

我的代码如下:

<?php  
namespace Application\Controller\SinglePage;
use PageController;
use Express;
class Search extends PageController
{
    private $cruise;
    public function view()
    {
        $entity = Express::getObjectByHandle('cruise');
        $list = new Concrete\Core\Express\EntryList($entity);
        $results = $list->getResults();
        $this->set('results', $results);
    }
}

谁能指出我正确的方向?

【问题讨论】:

    标签: php class express namespaces concrete5


    【解决方案1】:

    问题出在这一行:

    $list = new Concrete\Core\Express\EntryList($entity);
    

    你可以这样做:

    $list = new \Concrete\Core\Express\EntryList($entity); // Notice the backslash
    

    或者你可以导入 EntryList 类:

    <?php  
    namespace Application\Controller\SinglePage;
    use PageController;
    use Express;
    use Concrete\Core\Express\EntryList;
    
    class Search extends PageController
    {
        private $cruise;
        public function view()
        {
            $entity = Express::getObjectByHandle('cruise');
            $list = new EntryList($entity);
            $results = $list->getResults();
            $this->set('results', $results);
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多