Changes for page Home
Last modified by Isaac Mejia on 2025/12/15 18:27
From version 7.1
edited by Isaac Mejia
on 2025/12/05 16:27
on 2025/12/05 16:27
Change comment:
There is no comment for this version
To version 9.1
edited by Isaac Mejia
on 2025/12/05 16:52
on 2025/12/05 16:52
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -1,16 +1,44 @@ 1 1 {{velocity}} 2 2 ## KB Home (Main.WebHome) 3 3 4 -## Optionally, you can centralize your category list here. 5 -## Each entry: [ "Label", "SpaceName", "Short description" ] 6 -#set ($kbCategories = [ 7 - ["Member Management", "Member Management", "How to manage members, families, and profiles."], 8 - ["Configuration", "Configuration", "Set up locations, billing, and core system settings."], 9 - ["Billing & Payments", "Billing", "Invoices, collections, and payment processing."], 10 - ["Reporting & Analytics", "Reporting", "Understand your numbers and performance."], 11 - ["Integrations", "Integrations", "Connect eFit with other tools in your stack."] 12 -]) 4 +## ------------------------------------------------------------ 5 +## 1) Discover category pages automatically 6 +## - Category pages live at: Main.<CategoryLabel>.WebHome 7 +## - We query all docs in space=Main except WebHome + KB-Categories 8 +## ------------------------------------------------------------ 9 +#set ($xwql = 10 + "select doc.fullName, doc.title " + 11 + "from XWikiDocument doc " + 12 + "where doc.space = :space " + 13 + "and doc.name <> 'WebHome' " + 14 + "and doc.name <> 'KB-Categories' " + 15 + "and doc.hidden <> true " + 16 + "order by lower(doc.title)" 17 +) 13 13 19 +#set ($query = $services.query.xwql($xwql).bindValue("space", "Main")) 20 +#set ($rows = $query.execute()) 21 + 22 +## Build a list of document objects for convenience 23 +#set ($categories = []) 24 +#foreach ($row in $rows) 25 + #set ($fullName = $row[0]) ## e.g. "Main.Member Management" 26 + #set ($catDoc = $xwiki.getDocument($fullName)) 27 + #set ($discard = $categories.add($catDoc)) 28 +#end 29 + 30 +## ------------------------------------------------------------ 31 +## 2) Optional: description overrides by category label 32 +## Keys must match the *display title* (e.g. "Member Management") 33 +## ------------------------------------------------------------ 34 +#set ($categoryDescriptions = { 35 + "Member Management": "How to manage members, families, and profiles.", 36 + "Configuration": "Set up locations, billing, and core system settings.", 37 + "Billing & Payments": "Invoices, collections, and payment processing.", 38 + "Reporting & Analytics": "Understand your numbers and performance.", 39 + "Integrations": "Connect eFit with other tools in your stack." 40 +}) 41 + 14 14 {{html clean="false"}} 15 15 <div class="kb-home"> 16 16 ... ... @@ -38,28 +38,34 @@ 38 38 <h2 class="kb-section-title">Browse by category</h2> 39 39 40 40 <div class="kb-category-grid"> 41 - #foreach ($cat in $kbCategories) 42 - #set ($label = $cat.get(0)) 43 - #set ($spaceName = $cat.get(1)) 44 - #set ($desc = $cat.get(2)) 69 + #foreach ($catDoc in $categories) 70 + ## Label shown on the card 71 + #set ($label = $catDoc.displayTitle) ## e.g. "Member Management" 45 45 46 - ## Categorypagelives at Main.<Label>.WebHome(samepatternasour uploader)47 - # set($label=$cat.get(0))48 -#set ($spaceName=$cat.get(1))49 -#set ($ desc = $cat.get(2))73 + ## Space/page name used in the URL path: 74 + ## uploader created category pages as Main.<Label>.WebHome, 75 + ## so doc.name is the space segment we need (with spaces). 76 + #set ($spaceName = $catDoc.name) ## e.g. "Member Management" 50 50 51 -#set ($encoded = $escapetool.url($spaceName)) 52 -#set ($cleanUrl = "/bin/view/Main/$encoded") 78 + ## Description: use override map if present, else generic 79 + #set ($desc = $categoryDescriptions.get($label)) 80 + #if (!$desc) 81 + #set ($desc = "Articles and guides for " + $label) 82 + #end 53 53 54 -<a class="kb-card" href="$cleanUrl"> 55 - <div> 56 - <div class="kb-card-title">$escapetool.xml($label)</div> 57 - <div class="kb-card-body"> 58 - $escapetool.xml($desc) 59 - </div> 60 - </div> 61 - <div class="kb-card-meta">Category</div> 62 -</a> 84 + ## Build clean URL: /bin/view/Main/<SpaceName> (no trailing slash) 85 + #set ($encoded = $escapetool.url($spaceName)) 86 + #set ($cleanUrl = "/bin/view/Main/$encoded") 87 + 88 + <a class="kb-card" href="$cleanUrl"> 89 + <div> 90 + <div class="kb-card-title">$escapetool.xml($label)</div> 91 + <div class="kb-card-body"> 92 + $escapetool.xml($desc) 93 + </div> 94 + </div> 95 + <div class="kb-card-meta">Category</div> 96 + </a> 63 63 #end 64 64 </div> 65 65 </div>