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