Новости | FAQ | Авторы | Документация | В действии | Библиотека |
Инструменты | Полезные ссылки | Хостинги | Скачать | Примеры | Форум |
Mizter Egoist 15.04.2016 14:44 / 15.04.2016 14:46
Сделал рабочую модель с подзапросом:$tree[^table::sql{ SELECT t.dsc, h.anc AS pID, ( SELECT GROUP_CONCAT(u.url ORDER BY u.eID SEPARATOR '/') FROM pages AS u JOIN path AS r ON (u.eID = r.anc) WHERE 1 = 1 AND t.dsc = r.dsc AND r.anc > 0 ) AS uri, p.* FROM path AS t JOIN pages AS p ON (p.eID = t.dsc) JOIN path AS h ON (h.dsc = t.dsc AND h.lvl = 1) WHERE t.anc = $params.root ORDER BY h.anc }]Теперь извлекает и дерево и готовые адреса.
@tree[params] $tree[^table::sql{ SELECT t.dsc, h.anc AS pID FROM path AS t JOIN path AS h ON (h.dsc = t.dsc AND h.lvl = 1) WHERE t.anc = $params.root ORDER BY h.anc }] $tree[^tree.hash[pID][ $.type[table] $.distinct(true) ]] ^getURLs[$tree] @getURLs[pages] $result[^hash::sql{ SELECT t.dsc, GROUP_CONCAT(u.url ORDER BY u.eID SEPARATOR '/') AS uri, u.* FROM pages AS u JOIN path AS r ON (u.eID = r.anc) WHERE 1 AND t.dsc IN (^pages.menu{$pages.dsc}[,]) AND t.anc > 0 GROUP BY t.dsc }] ^print[$pages] @print[tree;pID][locals] $pID(^pID.int(^tree._at[first;key])) $cID[$tree.$pID]] $result[] ^if($cID){ $result[^cID.menu{ <div> <strong><a href="/$cID.uri">$cID.name</a></strong> ^print[$tree]($cID.dsc) </div> }] }