Skip to content

com_kb: search in the header, categories on the home page, snippets in results (supersedes #1932) - #1939

Merged
nkissebe merged 2 commits into
2.4-mainfrom
kb-search-views
Oct 7, 2026
Merged

nkissebe merged 2 commits into
2.4-mainfrom
kb-search-views

Conversation

@nkissebe

@nkissebe nkissebe commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Supersedes #1932 (ticket 2814), carrying its commit and adding the rework on top.

Why the split changed. The PR put a controller tweak and two template strings into core while the real UI change sat in a PURR template override on GitLab (tpl_doi, branch kuang_local_branch_doi_template_10022026). Most of that override is generic: a search box in the page header, category navigation on the home page, sort and category links that keep the search term, and highlighted snippets in search results. Those now live in core, so every hub gets them and the override stops drifting from core's views (the override had already lost the April accessibility fixes). What is PURR's alone, a contact-page link in place of the Answers/Wishlist/Support blocks and the sidebar-on-the-left layout, stays in the template: tpl_doi branch kb-core-views drops the full-view overrides and keeps a _help.php partial, a kb.css override and two strings. Deploy the two together.

What this adds to core

  • _search partial in the page header on both views (the region com_blog and com_answers already use), keeping the current sort.
  • _categories partial shared by both views; its links and the sort links carry the search term.
  • Article::snippet() with a highlighted excerpt under each search result and a "Results for …" line with a clear link.
  • _help partial for the home view's help links, so a template overrides one small file.
  • Category::link() falls back to the alias when there is no path: the synthetic "all" category has none, so core's own sort links on /kb/all carried an empty section and routed to the wrong task. The controller builds that category once (allCategory()) and gives the home view the same category/catid/filters contract as the category view.
  • The "Contact" strings go back to the template that uses them.

Verified with the doi overrides set aside on this hub: /kb, /kb/all, a real category, and searches on both show the header search box, the category sidebar, highlighted snippets, a results line, and sort/category links that keep the search term, with no PHP diagnostics. ArticleSnippetTest (9 cases, including the link fallback) passes; lint clean.

🤖 Generated with Claude Code

kuang5 and others added 2 commits October 7, 2026 14:49
…n results

Rework of the previous commit, which carried the core half of ticket
2814 as a controller tweak plus two template strings while the actual
UI lived in a PURR template override. The generic parts of that
override belong in core, where every hub gets them and they stop
drifting from core's views:

- The search box moves into the page header on both the home and the
  category view (com_blog and com_answers already use that region), via
  one _search partial. It keeps the current sort.
- The category sidebar becomes a _categories partial used by both
  views, so the home page gets category navigation beside its existing
  category grid. Its links, and the sort links, carry the search term,
  so narrowing or re-sorting does not drop a search.
- Searching shows a highlighted excerpt under each result.
  Article::snippet() strips field wrappers and markup, finds the phrase
  or else its earliest word, cuts on word boundaries, escapes, and
  wraps the matches in <mark>. A "Results for ..." line offers to clear
  the search.
- The home view's help links (Answers, Wishlist, Support) move to a
  _help partial, so a template that routes help elsewhere overrides
  that one small file instead of the whole view.
- Category::link() falls back to the alias when there is no stored
  path. The synthetic "all" category has none, so core's own sort links
  on /kb/all carried an empty section and routed to the wrong task.
  The controller builds that category in one allCategory() helper and
  gives the home view the same category/catid/filters contract as the
  category view.
- The two "Contact" strings go back to the template that uses them.

Tests cover snippet(): phrase and word matching, case, wrapper and tag
stripping, cutting, escaping of the term, and the link fallback.
@nkissebe
nkissebe merged commit 6b5395a into 2.4-main Oct 7, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants