我有一个从DB获取文档I的代码片段。
我想把这些放在Wayfinder的菜单中,但我无法让它工作。有人知道在Wayfinder中放置PHP变量的正确方法吗?我试过了,但没有成功:
echo '[[Wayfinder? &includeDocs=`' . $docid . '`]]';(PS:使用Revo)
编辑:添加更多代码
在一个坚果外壳中,我的代码从会话中获取登录的用户id,并找到他们的访问组。最终目标是显示指向其访问组中的资源的链接。这是代码片段的后面部分,在这里我获得了适当的资源ID,只需输出它们即可。
//RETRIEVE DOCUMENT GROUPS RELATED TO ACCESS GROUPS
$docgroups = "SELECT * FROM `modx_document_groups` WHERE `document_group` = '$target' ";
$docstmt = $modx->query($docgroups );
while ($docrow = $docstmt->fetch(PDO::FETCH_ASSOC)) {
$docid = $docrow['document'];
echo '[[Wayfinder? &startId=`0` &includeDocs=`' . $docid . '`]]';
}//END发布于 2012-12-18 08:15:15
在modx中,您的代码片段必须返回一个值才能在块/模板等中访问它。这是一种方法:
//MySnippet
<?php
// logic
$docIDs = array(1, 2, 23, 17);
return implode(',', $docIDs);然后你的寻路器调用就会使用这个代码片段:
// wayfinder call
[[!Wayfinder? &includeDocs=`[[!MySnippet]]`]]
// is the same as:
[[!Wayfinder? &includeDocs=`1,2,23,17`]]发布于 2012-12-18 20:15:19
在Modx革命中实现此目标的正确方法:
$c = $modx->newQuery('modResourceGroupResource');
$c->where(array( 'document_group' => $target ));
$docs = $modx->getCollection('modResourceGroupResource', $c);
$docids = array();
foreach($docs as $doc) {
$docids[] = $doc->get('document');
}
$output = $modx->runSnippet('Wayfinder',array(
'startId' => 0,
'includeDocs' => implode(',', $docids);
));
return $output;https://stackoverflow.com/questions/13924364
复制相似问题