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