3

我正在尝试使用 php 获取内容。但我的代码似乎不起作用。我正在使用ezcontentobjecttreenode::subtree函数,但它显示此错误:

Using $this when not in object context in /home/quejadore/site/kernel/classes/ezcontentobjecttreenode.php on line 2032

这是我的代码。

$params = $nodes =& eZContentObjectTreeNode::subTree( array( 
    'Depth' => 3,
    'SortBy' => array( 'published', false),
    'Limit' => 3,
    'ClassFilterType' => 'include',
    'ClassFilterArray' => array('article_v3'),
    'Attribute_filter' => array(array('article_v3/on_newsletter', '=',true))));

$nodes =& eZContentObjectTreeNode::subTree( $params, 21312);

任何人都可以帮忙吗?提前感谢

我现在已经编辑了我的代码(即使它还没有工作)。这是我现在所拥有的:

$params = array('Depth' => 3,
            'Limit' =>1,
            'IgnoreVisibility' => true,
            'Limitation' => array(),
            'ClassFilterType' => 'include',
            'ClassFilterArray' => array('article_v3'),
            'AttributeFilter' => array(array('article_v3/on_newsletter','=',true)));


$obj = new eZContentObjectTreeNode;
$nodes = $obj->subTree($params, 21312);
$dataMap =$nodes->attribute( 'data_map' );
$image =& $dataMap['image']->content();
$list =& $image->aliasList();
var_dump( $list['original']['url'] );
4

2 回答 2

1

所以我找到了解决方案。这是我的代码:

$params = array(
            'Depth' => 3,
            'AsObject' => true,
            'Limit' =>3,
            'SortBy' => array( 'published', false),
            'IgnoreVisibility' => true,
            'Limitation' => array(),
            'ClassFilterType' => 'include',
            'ClassFilterArray' => array('article_v3'),
            'AttributeFilter' => array(array('article_v3/on_newsletter', '=', true)));

$nodes = eZContentObjectTreeNode::subTreeByNodeID($params, 21312);

谢谢大家

于 2015-02-03T15:56:45.243 回答
0

如果您需要知道如何在 PHP 中使用 fetch 函数,请查看模板 fetch 函数参考,在您的情况下:https ://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference /模块/内容/获取功能/树

用它们的“分类”版本替换参数:attribute_filter成为AttributeFilterclass_filter_type成为ClassFilterArray等...请记住,即使您使用的是 PHP API,eZ Publish 也会处理可见性和角色权限。如果您想忽略这一点,'IgnoreVisibility' => true请在您的参数数组中使用。

另外,我不确定您要做什么,但您不需要通过引用来调用此方法&

于 2015-01-26T23:25:57.103 回答