From f11f702f9d41dfcfcc7a1fc3c5c175ec194d7aff Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Wed, 17 Apr 2024 18:00:02 +0200 Subject: [PATCH] MDL-81589 search: Use pix method to display global search icons Rather than exclusively relying on the image icon in the global search documents, the 'pix' method is used now, which allows to incorporate FontAwesome icons whenever they're available. --- search/classes/document.php | 2 ++ search/templates/result.mustache | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/search/classes/document.php b/search/classes/document.php index 85e116f6872..1ee3d3c5414 100644 --- a/search/classes/document.php +++ b/search/classes/document.php @@ -686,6 +686,8 @@ class document implements \renderable, \templatable { if ($docicon = $this->get_doc_icon()) { $data['icon'] = $output->image_url($docicon->get_name(), $docicon->get_component()); $data['iconurl'] = $data['icon']->out(false); + $data['iconname'] = $docicon->get_name(); + $data['iconcomponent'] = $docicon->get_component(); } $data['textformat'] = $this->get_text_format(); diff --git a/search/templates/result.mustache b/search/templates/result.mustache index 4b5c7d8f433..7b055ca3c55 100644 --- a/search/templates/result.mustache +++ b/search/templates/result.mustache @@ -45,6 +45,10 @@ * contextid * userid * timemodified + * iconname + * iconcomponent + * icon + * iconurl Example context (json): { @@ -61,12 +65,16 @@ [ "file1.txt", "file2.txt" - ] + ], + "iconname": "i/customfield" } }}

- {{#icon}}{{/icon}}{{{title}}} + {{#iconname}} + {{#pix}}{{iconname}}, {{iconcomponent}}{{/pix}} + {{/iconname}} + {{{title}}}

{{#content}}
{{{content}}}