Get File Icon

Author Message

Daniel Scheiner

Sunday 20 August 2006 9:16:17 am

Hi!

I want to show the Icon (PDF, etc.) of a File next to a link to the full-view of the file.
(ie have the "pdf-icon", the link "test" to the file "test.pdf" and the "file-size" and at the end a "delete that file - link"

is there any way to access the file-type-icon of a file?

thanks!
=)

Kristof Coomans

Sunday 20 August 2006 12:09:42 pm

Hello Daniel

Pass the mime_type field of the content object attribute attribute of type file ( http://ez.no/doc/ez_publish/technical_manual/3_8/reference/datatypes/file ) through the mimetype_icon template operator ( http://ez.no/doc/ez_publish/technical_manual/3_8/reference/template_operators/miscellaneous/mimetype_icon ).

{$attribute.content.mime_type|mimetype_icon( 'normal', $attribute.content.mime_type )}

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Daniel Scheiner

Tuesday 22 August 2006 7:28:28 am

cool! thanks!

and how do i actually show that image? (and put it in the same line as the name?)

Claudia Kosny

Tuesday 22 August 2006 1:45:00 pm

Hello Daniel

the code that Kristof posted returns a valid img tag so just put it wherever you want. Usually that would be in front of wherever you output the name of the file. How you get it in the same line depends on your stylesheet.
Example:
<a href="link to your file"> {$node.data_map.file.content.mime_type|mimetype_icon($icon_size)} {$node.data_map.file.content.original_filename}
</a>

This example assumes that your node has an attribute of datatype file which is called file.

If you need more information first check the links provided by Kristof -they should tell you everything you need to know. Also have a look at some of the templates for files, the most useful for me were the ezbinaryfile.tpl in the folder datatypes.

Greetings from Luxembourg

Claudia

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 20 2025 06:46:23
Script start
Timing: Jan 20 2025 06:46:23
Module start 'layout'
Timing: Jan 20 2025 06:46:23
Module start 'content'
Timing: Jan 20 2025 06:46:23
Module end 'content'
Timing: Jan 20 2025 06:46:23
Script end

Main resources:

Total runtime0.0151 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0065 590.1563152.6094
Module start 'layout' 0.00660.0033 742.765639.3984
Module start 'content' 0.00980.0034 782.164189.3828
Module end 'content' 0.01320.0019 871.546934.3047
Script end 0.0151  905.8516 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.003422.6204140.0002
Check MTime0.001912.5750140.0001
Mysql Total
Database connection0.00085.453510.0008
Mysqli_queries0.002315.349130.0008
Looping result0.00000.190910.0000
Template Total0.00159.910.0015
Template load0.00085.412510.0008
Template processing0.00074.494110.0007
Override
Cache load0.00063.746110.0006
General
dbfile0.00021.576480.0000
String conversion0.00000.113640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs