Wiki source code of Home

Version 18.1 by Isaac Mejia on 2025/12/05 17:50

Show last authors
1 {{velocity}}
2 ## ---------------------------------------------
3 ## KB Home (Main.WebHome)
4 ## Discover category landing pages dynamically.
5 ## ---------------------------------------------
6
7 ## 1) Find all top-level category pages under "Main"
8 ## We exclude:
9 ## - WebHome itself
10 ## - any technical KB* pages (KBStyles, KBArticleHeader, etc.)
11 ## - hidden docs
12 #set ($xwql =
13 "select doc.fullName, doc.title, doc.name " +
14 "from XWikiDocument doc " +
15 "where doc.space = 'Main' " +
16 "and doc.name <> 'WebHome' " +
17 "and doc.name not like 'KB%' " +
18 "and doc.hidden <> true " +
19 "order by lower(doc.title)"
20 )
21 #set ($query = $services.query.xwql($xwql))
22 #set ($rows = $query.execute())
23
24 ## 2) Icon map (optional overrides)
25 #set ($kbCategoryIcons = {
26 "Member Management": "👥",
27 "Configuration": "⚙️",
28 "Billing & Payments": "💳",
29 "Payment Management": "💳",
30 "Reporting & Analytics": "📊",
31 "Notifications": "🔔",
32 "Integrations": "🔗"
33 })
34
35 ## 3) Optional hand-authored descriptions for known categories
36 #set ($kbCategoryDescriptions = {
37 "Member Management": "How to manage members, families, and profiles.",
38 "Configuration": "Set up locations, billing, and core system settings.",
39 "Billing & Payments": "Invoices, collections, and payment processing.",
40 "Payment Management": "Articles and guides for Payment Management.",
41 "Reporting & Analytics": "Understand your numbers and performance.",
42 "Notifications": "Articles and guides for Notifications.",
43 "Integrations": "Connect Member Solutions with other tools in your stack."
44 })
45
46 ## 4) Build a normalized list of category objects
47 #set ($kbCategories = [])
48
49 #foreach ($row in $rows)
50 #set ($fullName = $row.get(0)) ## e.g. "Main.Member Management"
51 #set ($title = $row.get(1)) ## display title
52 #set ($pageName = $row.get(2)) ## page name, used in URL & article space
53 #set ($catDoc = $xwiki.getDocument($fullName))
54
55 ## Label shown on the card
56 #set ($label = $catDoc.displayTitle)
57 #if ("$!label" == "")
58 #set ($label = $pageName)
59 #end
60
61 ## Default description (auto-generated if we don't have a custom one)
62 #set ($desc = $kbCategoryDescriptions.get($label))
63 #if ("$!desc" == "")
64 #set ($desc = "Articles and guides for $label.")
65 #end
66
67 ## Article space follows the convention:
68 ## Main.<PageName with spaces replaced by underscores>
69 ## e.g. Member Management -> space "Main.Member_Management"
70 #set ($articleSpace = "Main." + $pageName.replace(" ", "_"))
71
72 ## Count non-hidden, non-WebHome pages in that article space
73 #set ($articleCount = 0)
74 #set ($countXwql =
75 "select count(doc.fullName) " +
76 "from XWikiDocument doc " +
77 "where doc.space = :space " +
78 "and doc.name <> 'WebHome' " +
79 "and doc.hidden <> true"
80 )
81 #set ($countQuery = $services.query.xwql($countXwql).bindValue("space", $articleSpace))
82
83 #try()
84 #set ($resultList = $countQuery.execute())
85 #if ($resultList && $resultList.size() > 0)
86 #set ($articleCount = $resultList.get(0))
87 #end
88 #catch($e)
89 ## Swallow query errors so we don't break the homepage
90 #end
91
92 ## Icon, with a sensible default
93 #set ($icon = $kbCategoryIcons.get($label))
94 #if ("$!icon" == "")
95 #set ($icon = "📘")
96 #end
97
98 ## Build clean URL: /bin/view/Main/<PageName> (no trailing slash)
99 #set ($encoded = $escapetool.url($pageName))
100 #set ($cleanUrl = "/bin/view/Main/$encoded")
101
102 ## Push into our categories array as a small map
103 #set ($entry = {
104 "label": $label,
105 "pageName": $pageName,
106 "desc": $desc,
107 "icon": $icon,
108 "url": $cleanUrl,
109 "count": $articleCount
110 })
111 #set ($discard = $kbCategories.add($entry))
112 #end
113
114 {{html clean="false"}}
115 <div class="kb-home">
116
117 <!-- HERO -->
118 <div class="kb-hero">
119 <h1 class="kb-hero-title">Member Solutions Knowledge Base</h1>
120 <p class="kb-hero-subtitle">
121 Guides, walkthroughs, and best practices to help you and your team get the most out of the platform.
122 </p>
123
124 <!-- Enhanced search box (still uses XWiki search under the hood) -->
125 <div class="kb-hero-search">
126 <form action="$xwiki.getURL('Main.WebHome', 'view')" method="get">
127 <input
128 type="text"
129 name="text"
130 placeholder="Search for an article (e.g. &quot;family membership&quot;)"
131 aria-label="Search the knowledge base"
132 />
133 </form>
134 </div>
135 </div>
136
137 <!-- CATEGORY GRID -->
138 <div class="kb-section">
139 <h2 class="kb-section-title">Browse by category</h2>
140
141 <div class="kb-category-grid">
142 #foreach ($cat in $kbCategories)
143 #set ($label = $cat.get("label"))
144 #set ($desc = $cat.get("desc"))
145 #set ($icon = $cat.get("icon"))
146 #set ($url = $cat.get("url"))
147 #set ($count = $cat.get("count"))
148
149 <a class="kb-card" href="$url">
150 <div>
151 <div class="kb-card-title">
152 <span class="kb-card-icon">$icon</span>
153 $escapetool.xml($label)
154 </div>
155 <div class="kb-card-body">
156 $escapetool.xml($desc)
157 </div>
158 </div>
159 <div class="kb-card-meta">
160 #if ($count == 1)
161 1 article
162 #elseif ($count > 1)
163 $count articles
164 #else
165 Category
166 #end
167 </div>
168 </a>
169 #end
170 </div>
171 </div>
172
173 <!-- Bottom CTA (support panel) -->
174 {{include reference="KBSupportCTA.WebHome"/}}
175
176 </div>
177 {{/html}}
178
179 {{/velocity}}