0
A
回答
3
如果你需要得到一个模板变量的值,你可以使用这个
$id = $modx->resource->get('id');//ID of current resource
$name = $modx->resource->get('pagetitle');//title of current resource
$val = $modx->resource->getTVValue('name_of_tv');//get tv value of current resource by name
$val = $modx->resource->getTVValue($tv_id);//get tv value of current resource by ID
要获得migx电视的IDX你需要这样的事 -
<?php
$docid = $modx->resource->get('id'); // id of curent resource
$tvname = 'name_of_your_tv'; // change to yours
$tv = $modx->getObject('modTemplateVar', array('name' => $tvname));
$outputvalue = $tv->renderOutput($docid);
$items = $modx->fromJSON($outputvalue);
$idx = 0; // initialize idx
$output = array();
foreach ($items as $key => $item) {
$idx++; // increase idx
$output[] = print_r($item,1); // test output
}
$outputSeparator = "\n";
$o = implode($outputSeparator, $output); // implode output
return $o;
0
因为您可能正在调用您的资源问题的代码段[你是吗?]你可以通过idx的片段....
[[!callMySnippet? &idx=[[+idx]] ]]
然后在你的代码片段:
$output = '';
$idx = $scriptProperties['idx'];
if ($idx==1) {
$output = "0";
}
return $output;
+1
'([[+ idx]] == 1)'在snippets modx中使用纯php,这是一个错误。也许你想写'($ idx == 1)'? – Vasis 2013-03-17 16:50:49
+0
@vasis - 对 - 我只是从OP中复制出来,没有想到。编辑和修复。 – 2013-03-17 22:07:27
相关问题
- 1. 镆铘和PDO:用PHP变量查询
- 2. 使用页面变量(镆铘,1.0.5)
- 3. 镆铘 - 问题与别名
- 4. 镆铘视频文件作为模板变量没有显示/播放
- 5. 镆铘getresources的foreach
- 6. 镆铘倒计时
- 7. 使用PHP和镆铘革命
- 8. 镆铘雷沃空变工况不返回变量
- 9. 镆铘与minishop2查看所有类别
- 10. 镆铘 - 为特定页面
- 11. 的if/else在镆铘
- 12. 保存变量会议的jQuery/AJAX - 镆铘革命
- 13. 如何将变量传递给一个子块在镆铘
- 14. 镆铘革命:获得第二级子
- 15. 镆铘IF返回空白页
- 16. 镆铘革命乘法值车
- 17. 镆铘登录色彩风格
- 18. 镆铘革命的Wayfinder回空行
- 19. 镆铘:摘录条和解析瓦尔
- 20. 镆铘插件手动安装
- 21. 镆铘:创建任何资源时
- 22. 镆铘getResources显示未上市资源
- 23. 电视输出镆铘革命
- 24. 镆铘MySQL的数组排序
- 25. 镆铘电子表格发出
- 26. 镆铘非www资源 - > WWW资源
- 27. 镆铘 - 用户个人资料照片
- 28. 意外的标记 - 镆铘革命2.2.9
- 29. 镆铘SimpleCart单页结帐不工作
- 30. 镆铘递减电视获得0
谢谢[[+ IDX]是migx项目的ID,我怎么能得到这个值? – user1758935 2013-03-17 12:29:45
检查我的更新答案。 – Vasis 2013-03-17 13:01:49