From b7a1187984fadde7dad4c1f5648a107dee50c7bc Mon Sep 17 00:00:00 2001 From: Jason Crome Date: Fri, 25 Feb 2022 11:24:54 -0500 Subject: [PATCH] Improve formatting of article results in self service Used CollectionList as the base for results so that we can provide a familiar experience with a minimal amount of work. --- share/html/SelfService/Article/Search.html | 73 +++++++++++----------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/share/html/SelfService/Article/Search.html b/share/html/SelfService/Article/Search.html index d3b75e4a9d8..5876e7a47fb 100644 --- a/share/html/SelfService/Article/Search.html +++ b/share/html/SelfService/Article/Search.html @@ -62,10 +62,10 @@
- + % if ($Articles_Content) { -% if ($articles_basics->Count || $articles_content->Count) { -<&|/l,$Articles_Content&>Articles matching [_1] +% if ($articles->Count) { +<% $articles->Count %> <&|/l,$Articles_Content&>Articles matching [_1] % } else { <&|/l,$Articles_Content&>No Articles match [_1] % } @@ -73,48 +73,51 @@
-% my %dedupe_articles; -% while (my $article = $articles_content->Next) { -% $dedupe_articles{$article->Id}++; -
- - <%$article->Name || loc('(no name)')%>: <%$article->Summary%> - -
-% } -% while (my $article = $articles_basics->Next) { -% next if $dedupe_articles{$article->Id}; -
- - <%$article->Name || loc('(no name)')%>: <%$article->Summary%> - -
+% if ($articles->BuildSelectCountQuery =~ /WHERE/i) { +<& /Elements/CollectionList, + Collection => $articles, + AllowSorting => 1, + OrderBy => \@OrderBy, + Order => \@Order, + Format => $format, + GenericQueryArgs => { Articles_Content => $Articles_Content, }, + &> % } - + <%init> use RT::Articles; -my $articles_content = RT::Articles->new( $session{'CurrentUser'} ); -my $articles_basics = RT::Articles->new( $session{'CurrentUser'} ); +my $articles = RT::Articles->new( $session{'CurrentUser'} ); if ( $ARGS{'Articles_Content'} ) { - $articles_content->LimitCustomField( VALUE => $ARGS{'Articles_Content'}, - OPERATOR => 'LIKE' ); - - $articles_basics->Limit( SUBCLAUSE => 'all', - FIELD => 'Name', - OPERATOR => 'LIKE', - VALUE => $ARGS{'Articles_Content'}, - ENTRYAGGREGATOR => "OR" ); - $articles_basics->Limit( SUBCLAUSE => 'all', - FIELD => 'Summary', - OPERATOR => 'LIKE', - VALUE => $ARGS{'Articles_Content'}, - ENTRYAGGREGATOR => "OR" ); + $articles->LimitCustomField( VALUE => $ARGS{'Articles_Content'}, + OPERATOR => 'LIKE', + ENTRYAGGREGATOR => "OR", + SUBCLAUSE => 'all' ); + $articles->Limit( SUBCLAUSE => 'all', + FIELD => 'Name', + OPERATOR => 'LIKE', + VALUE => $ARGS{'Articles_Content'}, + ENTRYAGGREGATOR => "OR" ); + $articles->Limit( SUBCLAUSE => 'all', + FIELD => 'Summary', + OPERATOR => 'LIKE', + VALUE => $ARGS{'Articles_Content'}, + ENTRYAGGREGATOR => "OR" ); } +my $format = q{ + '__id__/TITLE:#', + '__Name__/TITLE:Name', + '__ClassName__', + '__CreatedRelative__', + '__LastUpdatedRelative__', + '__Summary__', + '__Topics__', }; <%args> $Articles_Content => '' +@OrderBy => () +@Order => ()