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