Изменения документа HRlink. Новости об обновлениях
Редактировал(а) HRlink 22.08.2025
Сводка
-
Свойства страницы (1 изменено, 0 добавлено, 0 удалено)
Подробности
- Свойства страницы
-
- Содержимое
-
... ... @@ -1,13 +1,10 @@ 1 1 {{velocity}} 2 -## ------ НАСТРОЙКИ ------ 3 -#set($PERPAGE = 10) ## записей на страницу 2 +#set($PERPAGE = 10) ## записей на страницу 4 4 5 -## ------ ПРЕФИКС ВЕТКИ ------ 6 -#set($full = $doc.fullName) ## напр.: Blog.HRlink.-Novosti-ob-obnovleniiakh-.WebHome 7 -#set($lastDot = $full.lastIndexOf('.')) 8 -#set($PREFIX = $full.substring(0, $lastDot) + ".") ## напр.: Blog.HRlink.-Novosti-ob-obnovleniiakh-. 4 +## Родитель этой ветки — текущая страница 5 +#set($PARENT = $doc.fullName) 9 9 10 -## ------ПАГИНАЦИЯ ------7 +## Пагинация 11 11 #set($p = $request.get('p')) 12 12 #if(!$p) #set($p = 1) #end 13 13 #set($p = $numbertool.toInteger($p)) ... ... @@ -14,30 +14,34 @@ 14 14 #if($p < 1) #set($p = 1) #end 15 15 #set($offset = ($p - 1) * $PERPAGE) 16 16 17 -## ------СКОЛЬКОВСЕГОДОКУМЕНТОВВ ВЕТКЕ ------14 +## Считаем количество постов (Blog.BlogPostClass) 18 18 #set($total = $services.query.hql( 19 - "select count(doc.fullName) from XWikiDocument doc " + 20 - "where doc.fullName like :prefix" 21 -).bindValue("prefix", $PREFIX + "%").execute().get(0)) 16 + "select count(d.fullName) from XWikiDocument d, BaseObject o " + 17 + "where o.name = d.fullName and o.className = 'Blog.BlogPostClass' " + 18 + "and d.parent = :parent" 19 +).bindValue("parent", $PARENT).execute().get(0)) 22 22 23 -## ------ ТЕКУЩАЯ СТРАНИЦАДОКУМЕНТОВ(НОВЫЕ СВЕРХУ) ------24 -#set($ docs = $services.query.hql(25 - "select d oc.fullName from XWikiDocument doc " +26 - "where doc.fullName like:prefix" +27 - "order by d oc.date desc"28 -).bindValue("pre fix", $PREFIX + "%").setLimit($PERPAGE).setOffset($offset).execute())21 +## Достаём посты 22 +#set($rows = $services.query.hql( 23 + "select d.fullName from XWikiDocument d, BaseObject o " + 24 + "where o.name = d.fullName and o.className = 'Blog.BlogPostClass' " + 25 + "and d.parent = :parent order by d.date desc" 26 +).bindValue("parent", $PARENT).setLimit($PERPAGE).setOffset($offset).execute()) 29 29 30 -## ------ ВЫВОД ЛЕНТЫ ------ 31 -#foreach($fn in $docs) 28 +#foreach($fn in $rows) 32 32 #set($d = $xwiki.getDocument($fn)) 33 33 <article style="margin:14px 0; padding-bottom:10px; border-bottom:1px solid #e5e7eb"> 34 - <div style="color:#6b7280; font-size:.9em">$datetool.format('dd MMM yyyy', $d.date)</div> 35 - <h3 style="margin:.2rem 0"><a href="$d.getURL('view')">$escapetool.html($d.displayTitle)</a></h3> 31 + <div style="color:#6b7280; font-size:.9em"> 32 + $datetool.format('dd MMM yyyy', $d.date) 33 + </div> 34 + <h3 style="margin:.2rem 0"> 35 + <a href="$d.getURL('view')">$escapetool.html($d.displayTitle)</a> 36 + </h3> 36 36 <div>$!d.getPlainContent().substring(0,300)…</div> 37 37 </article> 38 38 #end 39 39 40 -## ------ПАГИНАЦИЯ ------41 +## Пагинация 41 41 #if($total > $PERPAGE) 42 42 #set($pages = ($total + $PERPAGE - 1) / $PERPAGE) 43 43 #set($base = $doc.getURL('view')) ... ... @@ -44,17 +44,9 @@ 44 44 #set($prev = $math.sub($p, 1)) 45 45 #set($next = $math.add($p, 1)) 46 46 <nav style="margin-top:1em; display:flex; gap:1em; align-items:center"> 47 - #if($p > 1) 48 - <a href="$base?p=$prev">← Назад</a> 49 - #else 50 - <span style="opacity:.5">← Назад</span> 51 - #end 48 + #if($p > 1)<a href="$base?p=$prev">← Назад</a>#else<span style="opacity:.5">← Назад</span>#end 52 52 <span>Стр. $p / $pages</span> 53 - #if($p < $pages) 54 - <a href="$base?p=$next">Далее →</a> 55 - #else 56 - <span style="opacity:.5">Далее →</span> 57 - #end 50 + #if($p < $pages)<a href="$base?p=$next">Далее →</a>#else<span style="opacity:.5">Далее →</span>#end 58 58 </nav> 59 59 #end 60 60 {{/velocity}}