Arrays 是否可以将对象发送到块而不是数组
在Modx中,我通常构建一个数组:Arrays 是否可以将对象发送到块而不是数组,arrays,object,modx,modx-revolution,chunks,Arrays,Object,Modx,Modx Revolution,Chunks,在Modx中,我通常构建一个数组: $props['example']['no_1'] = "example no. 1"; 然后用 return $modx->getChunk('chunkname', $props); 在我称之为的区块中: [[+example.no_1]] 是否可以将对象发送到块并显示它?比如像这样或者类似的 [[+example>getNo1()]] 不,但您可以这样做: return $modx->getChunk('chunkname',
$props['example']['no_1'] = "example no. 1";
然后用
return $modx->getChunk('chunkname', $props);
在我称之为的区块中:
[[+example.no_1]]
是否可以将对象发送到块并显示它?比如像这样或者类似的
[[+example>getNo1()]]
不,但您可以这样做:
return $modx->getChunk('chunkname', (array) $props);
如果要使用对象
提示:某些modx对象具有
toArray()
方法