| Новости | FAQ | Авторы | Документация | В действии | Библиотека |
| Инструменты | Полезные ссылки | Хостинги | Скачать | Примеры | Форум |
Mizter Egoist 01.02.2016 16:48
Добрый день!^rem{Получаем родителей, страницы у которых уровень вложенности = 1}
@getParentPages[iPagesID;iLevelID;iLimit]
^connect[$connect_string]{
$result[^table::sql{
SELECT
anc,
dsc,
lvl
FROM
path
WHERE
1 = 1
^if($iPagesID is "table"){
^if($iPagesID){
AND anc IN (^iPagesID.menu{$iPagesID.pID}[,])
}
}{
AND anc = ^iPagesID.int(0)
}
^if(def $iLevelID){
AND lvl = ^iLevelID.int(0)
}
ORDER BY
lvl
}[
^if(^iLimit.int(0)){
$.limit(^iLimit.int(0))
}
]]
}
^rem{Получаем потомков страниц}
@getPages[iPagesID;iLimit]
^connect[$connect_string]{
$result[^table::sql{
SELECT
*
FROM
pages p
JOIN
path t
ON
(p.pID = t.dsc)
WHERE
1 = 1
^if($iPagesID is "table"){
^if($iPagesID){
AND t.anc != t.dsc
AND t.anc IN (^iPagesID.menu{$iPagesID.anc}[,])
}
}{
AND t.anc != t.dsc
AND t.anc = ^iPagesID.int(0)
}
ORDER BY
anc,
lvl
}[
^if(^iLimit.int(0)){
$.limit(^iLimit.int(0))
}
]]
}
@createHashTree[tPage]
$result[^tPage.hash[anc][$.distinct[tables]]]
@printTreeItem[hPage;sBody]
$result[<li>$hPage.title^if(def $sBody){<ul>$sBody</ul>}</li>]
@printPages[hTree;iParentID][tLevel]
^if($hTree.[$iParentID]){
^hTree.[$iParentID].menu{
^printTreeItem[$hTree.[$iParentID].fields;^if($hTree.[$hTree.[$iParentID].id]){^printPages[$hTree;$hTree.[$iParentID].id]}]
}
}
^rem{Здесь все и вызывается}
@addPage[params]
^rem{Получаем страницы, у которых тип страницы указан как раздел}
$sections[^get.getPages[$.tID[1]]]
$rootPages[^getParentPages[$sections;1]]
$tPages[^getPages[$rootPages]]
$hTree[^createHashTree[$tPages]]
^printPages[$hTree]
^json:string[$hTree]В итоге ничего не выводит.{ "7":[ {"pID":"17","tID":"1","uID":"7","sort":"10","valid":"true","title":"Wassup","keywords":"","description":"","url":"wassup","name":"Wassup man!","content":"","img":"","price":"","create_at":"2016-01-30 19:13:50","update_at":"0000-00-00 00:00:00","anc":"7","dsc":"17","lvl":"2"}, {"pID":"27","tID":"1","uID":"7","sort":"10","valid":"true","title":"Test 2","keywords":"","description":"","url":"test_2","name":"Test 2","content":"","img":"","price":"","create_at":"2016-01-30 19:18:13","update_at":"0000-00-00 00:00:00","anc":"7","dsc":"27","lvl":"2"} ] }