Изменения документа HRlink. Новости об обновлениях
Редактировал(а) HRlink 22.08.2025
Сводка
-
Свойства страницы (1 изменено, 0 добавлено, 0 удалено)
Подробности
- Свойства страницы
-
- Содержимое
-
... ... @@ -1,28 +1,52 @@ 1 1 {{velocity}} 2 2 #set($PERPAGE = 10) 3 3 4 -## Текущ еепространство(space)категории. Для WebHome это именно нужная ветка.5 -#set($ SPACE= $doc.space)4 +## 1) Текущая страница категории 5 +#set($full = $doc.fullName) 6 6 7 -## Пагинация 7 +## 2) Родитель может храниться как "...WebHome" или без него. 8 +## Сформируем обе ссылки и превратим их в DocumentReference. 9 +#set($pWith = $full.endsWith('.WebHome') ? $full : $full + '.WebHome') 10 +#set($pBare = $full.endsWith('.WebHome') ? $full.substring(0, $full.length() - 8) : $full) 11 + 12 +#set($parentRefWith = $services.model.resolveDocument($pWith)) 13 +#set($parentRefBare = $services.model.resolveDocument($pBare)) 14 + 15 +## Префикс ветки (для фоллбэка по fullName, включая подкатегории) 16 +#set($prefix = $pBare + '.') 17 + 18 +## 3) Пагинация 8 8 #set($p = $request.get('p')) #if(!$p) #set($p = 1) #end 9 9 #set($p = $numbertool.toInteger($p)) #if($p < 1) #set($p = 1) #end 10 10 #set($offset = ($p - 1) * $PERPAGE) 11 11 12 -## С колькодокументовв этомspace (исключаемсамWebHome)23 +## 4) Сначала ищем детей по parent = (ref c WebHome ИЛИ без него) 13 13 #set($total = $services.query.xwql( 14 14 "select count(doc.fullName) from Document doc " + 15 - "where doc. space = :spanddoc.name<>'WebHome'"16 -).bindValue(' sp', $SPACE).execute().get(0))26 + "where doc.parent = :r1 or doc.parent = :r2" 27 +).bindValue('r1', $parentRefWith).bindValue('r2', $parentRefBare).execute().get(0)) 17 17 18 -## Берём текущую порцию документов, новые сверху 19 -#set($rows = $services.query.xwql( 20 - "select doc.fullName from Document doc " + 21 - "where doc.space = :sp and doc.name <> 'WebHome' " + 22 - "order by doc.date desc" 23 -).bindValue('sp', $SPACE).setLimit($PERPAGE).setOffset($offset).execute()) 29 +#set($rows = []) 30 +#if($total > 0) 31 + #set($rows = $services.query.xwql( 32 + "select doc.fullName from Document doc " + 33 + "where doc.parent = :r1 or doc.parent = :r2 " + 34 + "order by doc.date desc" 35 + ).bindValue('r1', $parentRefWith).bindValue('r2', $parentRefBare).setLimit($PERPAGE).setOffset($offset).execute()) 36 +#end 24 24 38 +## 5) Если вдруг пусто — берём все документы по префиксу fullName (включая подкатегории) 25 25 #if($total == 0) 40 + #set($total = $services.query.xwql( 41 + "select count(doc.fullName) from Document doc where doc.fullName like :prefix" 42 + ).bindValue('prefix', $prefix + '%').execute().get(0)) 43 + #set($rows = $services.query.xwql( 44 + "select doc.fullName from Document doc where doc.fullName like :prefix order by doc.date desc" 45 + ).bindValue('prefix', $prefix + '%').setLimit($PERPAGE).setOffset($offset).execute()) 46 +#end 47 + 48 +## 6) Рендер ленты + пагинация 49 +#if($total == 0) 26 26 <p>Пока нет публикаций в этой ветке.</p> 27 27 #else 28 28 #foreach($fn in $rows) ... ... @@ -36,9 +36,9 @@ 36 36 37 37 #if($total > $PERPAGE) 38 38 #set($pages = ($total + $PERPAGE - 1) / $PERPAGE) 39 - #set($base = $doc.getURL('view')) 40 - #set($prev = $math.sub($p, 1)) 41 - #set($next = $math.add($p, 1)) 63 + #set($base = $doc.getURL('view')) 64 + #set($prev = $math.sub($p, 1)) 65 + #set($next = $math.add($p, 1)) 42 42 <nav style="margin-top:1em; display:flex; gap:1em; align-items:center"> 43 43 #if($p > 1)<a href="$base?p=$prev">← Назад</a>#else<span style="opacity:.5">← Назад</span>#end 44 44 <span>Стр. $p / $pages</span>