Изменения документа HRlink. Новости об обновлениях
Редактировал(а) HRlink 22.08.2025
Сводка
-
Свойства страницы (1 изменено, 0 добавлено, 0 удалено)
Подробности
- Свойства страницы
-
- Содержимое
-
... ... @@ -1,61 +1,36 @@ 1 1 {{velocity}} 2 -## ===== Настройки ===== 3 3 #set($PERPAGE = 10) 4 4 5 -## Родитель категории и префиксветки(например: Blog.HRlink.-Novosti-ob-obnovleniiakh-.)4 +## 1) Родитель — текущая страница категории 6 6 #set($PARENT = $doc.fullName) 7 -#set($full = $doc.fullName) 8 -#set($lastDot = $full.lastIndexOf('.')) 9 -#set($PREFIX = $full.substring(0, $lastDot) + ".") 10 10 11 -## Текущаястраница пагинации7 +## 2) Пагинация 12 12 #set($p = $request.get('p')) #if(!$p) #set($p = 1) #end 13 13 #set($p = $numbertool.toInteger($p)) #if($p < 1) #set($p = 1) #end 14 14 #set($offset = ($p - 1) * $PERPAGE) 15 15 16 -## ===СтратегияA:по родителю+BlogPostClass===12 +## 3) Сначала пробуем просто по parent (все дочерние документы) 17 17 #set($total = $services.query.hql( 18 - "select count(d.fullName) from XWikiDocument d, BaseObject o " + 19 - "where o.name=d.fullName and o.className='Blog.BlogPostClass' " + 20 - "and d.parent=:parent" 14 + "select count(d.fullName) from XWikiDocument d where d.parent = :parent" 21 21 ).bindValue("parent", $PARENT).execute().get(0)) 22 22 23 -#set($rows = []) 24 -#if($total > 0) 25 - #set($rows = $services.query.hql( 26 - "select d.fullName from XWikiDocument d, BaseObject o " + 27 - "where o.name=d.fullName and o.className='Blog.BlogPostClass' " + 28 - "and d.parent=:parent order by d.date desc" 29 - ).bindValue("parent", $PARENT).setLimit($PERPAGE).setOffset($offset).execute()) 30 -#end 17 +#set($rows = $services.query.hql( 18 + "select d.fullName from XWikiDocument d " + 19 + "where d.parent = :parent order by d.date desc" 20 +).bindValue("parent", $PARENT).setLimit($PERPAGE).setOffset($offset).execute()) 31 31 32 -## ===СтратегияB:попрефиксу+ BlogPostClass (включаяподкатегории)===22 +## 4) Если вдруг пусто (редкие конфигурации), подстрахуемся выборкой по space 33 33 #if($total == 0) 24 + #set($SPACE = $doc.space) 34 34 #set($total = $services.query.hql( 35 - "select count(d.fullName) from XWikiDocument d, BaseObject o " + 36 - "where o.name=d.fullName and o.className='Blog.BlogPostClass' " + 37 - "and d.fullName like :prefix" 38 - ).bindValue("prefix", $PREFIX + "%").execute().get(0)) 39 - #if($total > 0) 40 - #set($rows = $services.query.hql( 41 - "select d.fullName from XWikiDocument d, BaseObject o " + 42 - "where o.name=d.fullName and o.className='Blog.BlogPostClass' " + 43 - "and d.fullName like :prefix order by d.date desc" 44 - ).bindValue("prefix", $PREFIX + "%").setLimit($PERPAGE).setOffset($offset).execute()) 45 - #end 46 -#end 47 - 48 -## === Стратегия C: по префиксу без класса (фоллбек на нестандартные посты) === 49 -#if($total == 0) 50 - #set($total = $services.query.hql( 51 - "select count(d.fullName) from XWikiDocument d where d.fullName like :prefix" 52 - ).bindValue("prefix", $PREFIX + "%").execute().get(0)) 26 + "select count(d.fullName) from XWikiDocument d where d.space = :space" 27 + ).bindValue("space", $SPACE).execute().get(0)) 53 53 #set($rows = $services.query.hql( 54 - "select d.fullName from XWikiDocument d where d. fullNamelike:prefixorder by d.date desc"55 - ).bindValue("p refix", $PREFIX + "%").setLimit($PERPAGE).setOffset($offset).execute())29 + "select d.fullName from XWikiDocument d where d.space = :space order by d.date desc" 30 + ).bindValue("space", $SPACE).setLimit($PERPAGE).setOffset($offset).execute()) 56 56 #end 57 57 58 -## ===Вывод ленты===33 +## 5) Рендер ленты 59 59 #if($total == 0) 60 60 <p>Пока нет публикаций в этой ветке.</p> 61 61 #else