Изменения документа HRlink. Новости об обновлениях
Редактировал(а) HRlink 22.08.2025
Сводка
-
Свойства страницы (1 изменено, 0 добавлено, 0 удалено)
Подробности
- Свойства страницы
-
- Содержимое
-
... ... @@ -1,36 +1,61 @@ 1 1 {{velocity}} 2 +## ===== Настройки ===== 2 2 #set($PERPAGE = 10) 3 3 4 -## 1)Родитель— текущая страницакатегории5 +## Родитель категории и префикс ветки (например: Blog.HRlink.-Novosti-ob-obnovleniiakh-.) 5 5 #set($PARENT = $doc.fullName) 7 +#set($full = $doc.fullName) 8 +#set($lastDot = $full.lastIndexOf('.')) 9 +#set($PREFIX = $full.substring(0, $lastDot) + ".") 6 6 7 -## 2)Пагинация11 +## Текущая страница пагинации 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 -## 3)Сначалапробуемпростопоparent(все дочерние документы)16 +## === Стратегия A: по родителю + BlogPostClass === 13 13 #set($total = $services.query.hql( 14 - "select count(d.fullName) from XWikiDocument d where d.parent = :parent" 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" 15 15 ).bindValue("parent", $PARENT).execute().get(0)) 16 16 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()) 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 21 21 22 -## 4)Если вдруг пусто(редкие конфигурации),подстрахуемся выборкойпо space32 +## === Стратегия B: по префиксу + BlogPostClass (включая подкатегории) === 23 23 #if($total == 0) 24 - #set($SPACE = $doc.space) 25 25 #set($total = $services.query.hql( 26 - "select count(d.fullName) from XWikiDocument d where d.space = :space" 27 - ).bindValue("space", $SPACE).execute().get(0)) 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)) 28 28 #set($rows = $services.query.hql( 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())54 + "select d.fullName from XWikiDocument d where d.fullName like :prefix order by d.date desc" 55 + ).bindValue("prefix", $PREFIX + "%").setLimit($PERPAGE).setOffset($offset).execute()) 31 31 #end 32 32 33 -## 5)Рендерленты58 +## === Вывод ленты === 34 34 #if($total == 0) 35 35 <p>Пока нет публикаций в этой ветке.</p> 36 36 #else