Изменения документа HRlink. Новости об обновлениях
Редактировал(а) HRlink 22.08.2025
Сводка
-
Свойства страницы (1 изменено, 0 добавлено, 0 удалено)
Подробности
- Свойства страницы
-
- Содержимое
-
... ... @@ -1,10 +1,67 @@ 1 1 {{velocity}} 2 -#set($category = "Blog.HRlink.-Novosti-ob-obnovleniiakh-.WebHome") 3 -#set($query = ", BaseObject as obj, StringProperty as cat where obj.name = doc.fullName and obj.className = 'Blog.BlogPostClass' and cat.id.id = obj.id and cat.name = 'category' and cat.value = :category order by doc.creationDate desc") 4 -#set($results = $services.query.hql($query).bindValue('category', $category).setLimit(15).execute()) 2 +#set($PERPAGE = 10) 5 5 6 -#foreach($docName in $results) 7 - #set($doc = $xwiki.getDocument($docName)) 8 - #displayBlogPost($doc) 4 +## --- Текущая страница категории --- 5 +#set($parentRef = $doc.documentReference) ## надёжно даже с "\." в именах 6 +#set($full = $doc.fullName) ## напр.: Blog.HRlink.-Novosti-ob-obnovleniiakh-.WebHome 7 + 8 +## Префикс для фоллбэка: убираем .WebHome и добавляем точку 9 +#set($prefix = $full) 10 +#if($full.endsWith('.WebHome')) 11 + #set($prefix = $full.substring(0, $full.length() - 8)) 9 9 #end 13 +#set($prefix = $prefix + '.') 14 + 15 +## --- Пагинация --- 16 +#set($p = $request.get('p')) #if(!$p) #set($p = 1) #end 17 +#set($p = $numbertool.toInteger($p)) #if($p < 1) #set($p = 1) #end 18 +#set($offset = ($p - 1) * $PERPAGE) 19 + 20 +## --- A) дети по parent = текущая страница (DocumentReference) --- 21 +#set($total = $services.query.xwql( 22 + "select count(doc.fullName) from Document doc where doc.parent = :p" 23 +).bindValue('p', $parentRef).execute().get(0)) 24 + 25 +#set($rows = []) 26 +#if($total > 0) 27 + #set($rows = $services.query.xwql( 28 + "select doc.fullName from Document doc where doc.parent = :p order by doc.date desc" 29 + ).bindValue('p', $parentRef).setLimit($PERPAGE).setOffset($offset).execute()) 30 +#end 31 + 32 +## --- B) если вдруг пусто — берём по префиксу полного имени (включая подкатегории) --- 33 +#if($total == 0) 34 + #set($total = $services.query.xwql( 35 + "select count(doc.fullName) from Document doc where doc.fullName like :pref" 36 + ).bindValue('pref', $prefix + '%').execute().get(0)) 37 + #set($rows = $services.query.xwql( 38 + "select doc.fullName from Document doc where doc.fullName like :pref order by doc.date desc" 39 + ).bindValue('pref', $prefix + '%').setLimit($PERPAGE).setOffset($offset).execute()) 40 +#end 41 + 42 +## --- Рендер ленты и пагинация --- 43 +#if($total == 0) 44 + <p>Пока нет публикаций в этой ветке.</p> 45 +#else 46 + #foreach($fn in $rows) 47 + #set($d = $xwiki.getDocument($fn)) 48 + <article style="margin:14px 0; padding-bottom:10px; border-bottom:1px solid #e5e7eb"> 49 + <div style="color:#6b7280; font-size:.9em">$datetool.format('dd MMM yyyy', $d.date)</div> 50 + <h3 style="margin:.2rem 0"><a href="$d.getURL('view')">$escapetool.html($d.displayTitle)</a></h3> 51 + <div>$!d.getPlainContent().substring(0,300)…</div> 52 + </article> 53 + #end 54 + 55 + #if($total > $PERPAGE) 56 + #set($pages = ($total + $PERPAGE - 1) / $PERPAGE) 57 + #set($base = $doc.getURL('view')) 58 + #set($prev = $math.sub($p, 1)) 59 + #set($next = $math.add($p, 1)) 60 + <nav style="margin-top:1em; display:flex; gap:1em; align-items:center"> 61 + #if($p > 1)<a href="$base?p=$prev">← Назад</a>#else<span style="opacity:.5">← Назад</span>#end 62 + <span>Стр. $p / $pages</span> 63 + #if($p < $pages)<a href="$base?p=$next">Далее →</a>#else<span style="opacity:.5">Далее →</span>#end 64 + </nav> 65 + #end 66 +#end 10 10 {{/velocity}}