Skip to content

Commit

Permalink
MDL-81589 search: Use pix method to display global search icons
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sarjona committed May 27, 2024
1 parent d32844c commit f11f702
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions search/classes/document.php
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,8 @@ public function export_doc(\renderer_base $output): array {
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();

Expand Down
12 changes: 10 additions & 2 deletions search/templates/result.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
* contextid
* userid
* timemodified
* iconname
* iconcomponent
* icon
* iconurl
Example context (json):
{
Expand All @@ -61,12 +65,16 @@
[
"file1.txt",
"file2.txt"
]
],
"iconname": "i/customfield"
}
}}
<div class="result">
<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>
{{#content}}
<div class="result-content">{{{content}}}</div>
Expand Down

0 comments on commit f11f702

Please sign in to comment.