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.
This commit is contained in:
Sara Arjona 2024-04-17 18:00:02 +02:00
parent d32844ce29
commit f11f702f9d
No known key found for this signature in database
2 changed files with 12 additions and 2 deletions

View File

@ -686,6 +686,8 @@ class document implements \renderable, \templatable {
if ($docicon = $this->get_doc_icon()) { if ($docicon = $this->get_doc_icon()) {
$data['icon'] = $output->image_url($docicon->get_name(), $docicon->get_component()); $data['icon'] = $output->image_url($docicon->get_name(), $docicon->get_component());
$data['iconurl'] = $data['icon']->out(false); $data['iconurl'] = $data['icon']->out(false);
$data['iconname'] = $docicon->get_name();
$data['iconcomponent'] = $docicon->get_component();
} }
$data['textformat'] = $this->get_text_format(); $data['textformat'] = $this->get_text_format();

View File

@ -45,6 +45,10 @@
* contextid * contextid
* userid * userid
* timemodified * timemodified
* iconname
* iconcomponent
* icon
* iconurl
Example context (json): Example context (json):
{ {
@ -61,12 +65,16 @@
[ [
"file1.txt", "file1.txt",
"file2.txt" "file2.txt"
] ],
"iconname": "i/customfield"
} }
}} }}
<div class="result"> <div class="result">
<h4 class="result-title"> <h4 class="result-title">
{{#icon}}<img class="icon" alt="" src="{{{icon}}}">{{/icon}}<a href="{{{docurl}}}">{{{title}}}</a> {{#iconname}}
{{#pix}}{{iconname}}, {{iconcomponent}}{{/pix}}
{{/iconname}}
<a href="{{{docurl}}}">{{{title}}}</a>
</h4> </h4>
{{#content}} {{#content}}
<div class="result-content">{{{content}}}</div> <div class="result-content">{{{content}}}</div>