In template - if/else check for filetype (by extension)?

galmoid

Joined: 2005-11-07
Posts: 364
Posted: Fri, 2006-01-27 21:33

I am in search of a way to check what type of file an item
is ($child.???). I want to differentiate between, for
instance, .jpg, .mov, .mpg and change the way each file is
handled. If the file is .jpg then I want my template to
show a thumbnail which links to the larger image. If the
file is a .mov/.mpg then I want to bypass the thumbnail
and href; instead, use an embed/src.

In summary:
If filetype = jpg then
href=....
elseif filetype = mov then
embed src=....

I get this to, partially (without the if/else), do what I
want by using:
[code]
{g->url arg1="view=core.DownloadItem" arg2="itemId=`$child.id`"}
{/code]
but I'd like finer control tan what that gives me.

Any possibility to accomplish this?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2006-01-28 14:23

{if $child.mimeType == 'image/jpeg'}
...
{elseif $child.mimeType == 'image/jpeg'}
...
{else}
...
{/if}

install and activate the mime module to see a complete list of handled mime types.

 
galmoid

Joined: 2005-11-07
Posts: 364
Posted: Sat, 2006-01-28 17:19

valiant,
Thank You. This is exactly what I was looking for.