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. 鏌鋣視頻文件作爲模板變量沒有顯示/播放
- 2. 鏌鋣倒計時
- 3. 鏌鋣getresources的foreach
- 4. 鏌鋣雷沃空變工況不返回變量
- 5. 鏌鋣革命FormIt傳遞url變量,形成
- 6. 保存變量會議的jQuery/AJAX - 鏌鋣革命
- 7. 鏌鋣IF返回空白頁
- 8. 鏌鋣插件手動安裝
- 9. 鏌鋣:摘錄條和解析瓦爾
- 10. 鏌鋣遞減電視獲得0
- 11. 鏌鋣:創建任何資源時
- 12. 鏌鋣getResources顯示未上市資源
- 13. 電視輸出鏌鋣革命
- 14. 鏌鋣SimpleCart單頁結帳不工作
- 15. 鏌鋣htaccess的鏈接不工作
- 16. 鏌鋣革命的Wayfinder回空行
- 17. 鏌鋣登錄色彩風格
- 18. 鏌鋣非www資源 - > WWW資源
- 19. 鏌鋣REVO + PHP的MySQL數據插入到指定的錶行
- 20. PHP排序姓氏的數組由空格在鏌鋣
- 21. PHP模板變量<?=
- 22. 使用變量與模板
- 23. 鏌鋣:佔用資源展示兒童,而不是資源數量
- 24. 鏌鋣埃沃:無法創建images文件夾
- 25. 創建在鏌鋣雷沃新文章不起作用
- 26. 鏌鋣 - 獲得「PAGETITLE」,並從兄弟姐妹
- 27. 鏌鋣網站被黑客攻擊怎麼解決
- 28. 鏌鋣:在錯誤記憶電子表格輸入領域
- 29. 鏌鋣革命 - 發生超時每分鐘導致退出
- 30. 鏌鋣p拇指如何顯示圖像高度正確
謝謝[[+ IDX]是migx項目的ID,我怎麼能得到這個值? – user1758935 2013-03-17 12:29:45
檢查我的更新答案。 – Vasis 2013-03-17 13:01:49