diff options
author | Jason Crome <jcrome@bestpractical.com> | 2022-02-25 19:24:54 +0300 |
---|---|---|
committer | Jason Crome <jcrome@bestpractical.com> | 2022-02-25 19:24:54 +0300 |
commit | b7a1187984fadde7dad4c1f5648a107dee50c7bc (patch) | |
tree | def8ada5896490e7222ba03bcfdc0e3c26bae86c | |
parent | ebae4a6d01e442641a65b8bab2dd185a9f836a42 (diff) |
Improve formatting of article results in self service5.0/improve-article-search-result-formatting
Used CollectionList as the base for results so that we can provide a
familiar experience with a minimal amount of work.
-rw-r--r-- | share/html/SelfService/Article/Search.html | 73 |
1 files changed, 38 insertions, 35 deletions
diff --git a/share/html/SelfService/Article/Search.html b/share/html/SelfService/Article/Search.html index d3b75e4a9d..5876e7a47f 100644 --- a/share/html/SelfService/Article/Search.html +++ b/share/html/SelfService/Article/Search.html @@ -62,10 +62,10 @@ </form> <div class="form-row"> - <span class="label col-auto"> + <span class="label col-auto font-weight-bold"> % 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 @@ </span> </div> -% my %dedupe_articles; -% while (my $article = $articles_content->Next) { -% $dedupe_articles{$article->Id}++; - <div class="form-row"> - <span class="value col-auto"> - <a href="Display.html?id=<%$article->Id%>"><%$article->Name || loc('(no name)')%>: <%$article->Summary%></a> - </span> - </div> -% } -% while (my $article = $articles_basics->Next) { -% next if $dedupe_articles{$article->Id}; - <div class="form-row"> - <span class="value col-auto"> - <a href="Display.html?id=<%$article->Id%>"><%$article->Name || loc('(no name)')%>: <%$article->Summary%></a> - </span> - </div> +% if ($articles->BuildSelectCountQuery =~ /WHERE/i) { +<& /Elements/CollectionList, + Collection => $articles, + AllowSorting => 1, + OrderBy => \@OrderBy, + Order => \@Order, + Format => $format, + GenericQueryArgs => { Articles_Content => $Articles_Content, }, + &> % } -</div> + <%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{ + '<a href="__WebPath__/Articles/Article/Display.html?id=__id__">__id__</a>/TITLE:#', + '<a href="__WebPath__/Articles/Article/Display.html?id=__id__">__Name__</a>/TITLE:Name', + '__ClassName__', + '__CreatedRelative__', + '__LastUpdatedRelative__', + '__Summary__', + '__Topics__', }; </%init> <%args> $Articles_Content => '' +@OrderBy => () +@Order => () </%args> |