question about using pdf in gallery2

isy

Joined: 2011-12-23
Posts: 8
Posted: Sat, 2012-05-12 16:58

Hello,

i have installed imageMagick and i can upload some pdf in my gallery. Gallery display pdf thumbs, everything work.
When i click on it, it displays the first page of the pdf as a photo. You have to click on "Download document in original format" in order to view the entire pdf with adobe reader (in full screen).

I just want to know if it's possible to open the pdf directly by clicking on the pdf thumb, and skipping the step where it displays the first page of the pdf as a photo.

i hope my explanation is clear :)

Thank you

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sat, 2012-05-12 18:56

best way would be to modify /themes/your theme/templates/local/album.tpl <- you may have to copy the original here

the find where it is looping through the $child items and test for application/pdf and set the view to DownloadItem url instead of a ShowItem url

{if $child.mimeType == 'application/pdf'}
  {capture assign=linkUrl}{g->url arg1="view=core.DownloadItem" arg2="itemId=`$child.id`"}{/capture}
{/if}

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
isy

Joined: 2011-12-23
Posts: 8
Posted: Sat, 2012-05-12 21:34

thank you for the answer,

it doesn't work yet because i am a little bit lost, am i doing right ?

Quote:
{foreach from=$theme.children item=child}

{* Move to a new row *}
{if ($childrenInColumnCount == $theme.params.columns)}
</tr>
<tr valign="top">
{assign var="childrenInColumnCount" value=0}
{/if}

{assign var=childrenInColumnCount value="`$childrenInColumnCount+1`"}
<td class="{if $child.canContainChildren}giAlbumCell{else}giItemCell{/if}"
style="width: {$theme.columnWidthPct}%">

{if $child.mimeType == 'application/pdf'}
{capture assign=linkUrl}{g->url arg1="view=core.DownloadItem" arg2="itemId=`$child.id`"}{/capture}
{/if}

{if ($child.canContainChildren || $child.entityType == 'GalleryLinkItem')}
{assign var=frameType value="albumFrame"}
{capture assign=linkUrl}{g->url arg1="view=core.ShowItem"
arg2="itemId=`$child.id`"}{/capture}

. . .

is it the right place to put the code (in bold) ?

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sat, 2012-05-12 21:51

put it just above this line:
{elseif isset($child.thumbnail)}

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
isy

Joined: 2011-12-23
Posts: 8
Posted: Sun, 2012-05-13 08:40

Thank you very much, it works !
I really appreciate your help

i put it below the line because noting happened when i put it above.

Thanks again

 
mansoorahmedkhan

Joined: 2012-08-03
Posts: 2
Posted: Fri, 2012-08-03 07:30

I tried to follow this post to achieve the exact same requirement. However, i have fol to share:

1. the folder named "local" is not found at the path "~/gallery2/themes/matrix/"

2. even though i created the folder and copied the file "album.tpl" in it

3. i made the necessary modifications as you suggested, BUT it just wont work for me !

can you again elaborate by sharing the file or file content of your album.tpl, so that i am able to resolve it !!!

Thanks in anticipation.

 
isy

Joined: 2011-12-23
Posts: 8
Posted: Fri, 2012-08-03 17:43

I can't share the file content because i'm using my tab.
In fact, i don't use a copy of the file (i know its bad) so i dont have the local folder. I modify the original file.
It should work like this

Isy

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Fri, 2012-08-03 19:07

Remember, when you edit templates you must clear your template cache to see changes
FAQ: How can I clear cached data?

-s

 
mansoorahmedkhan

Joined: 2012-08-03
Posts: 2
Posted: Tue, 2012-08-07 03:32

even after many tries and clearing the template cache as well i cant make it work (possibly owing to my lack of php knowledge)....
Here is the partial code of my album.tpl....

.
.
.
{/g->container}

{if $child.mimeType == 'application/pdf'}
{capture assign=linkUrl}{g->url arg1="view=core.DownloadItem" arg2="itemId=`$child.id`"}{/capture}
{/if}

{elseif isset($child.thumbnail)}
<a href="{$linkUrl}">
{g->image item=$child image=$child.thumbnail class="giThumbnail"}
</a>
{else}
<a href="{$linkUrl}" class="giMissingThumbnail">
{g->text text="no thumbnail"}
</a>
{/if}
</div>
.
.
.

What am i doing wrong .... please help correct it .... Thanks.

 
scarpy

Joined: 2011-04-21
Posts: 5
Posted: Wed, 2013-04-24 13:13

SOLVED !
I had to put 's piece of code a few lines up the position you suggested:

This is my album.tpl working.
----
<div>
{if isset($theme.params.$frameType) && isset($child.thumbnail)}

{g->container type="imageframe.ImageFrame" frame=$theme.params.$frameType
width=$child.thumbnail.width height=$child.thumbnail.height}

<!-- PDF CHECK - start --> {if $child.mimeType == 'application/pdf'}<!-- 002 -->
{capture assign=linkUrl}{g->url arg1="view=core.DownloadItem" arg2="itemId=`$child.id`"}{/capture}
{/if}
<!-- PDF CHECK - end -->
<a href="{$linkUrl}">

{g->image id="%ID%" item=$child image=$child.thumbnail
class="%CLASS% giThumbnail"}
</a>
{/g->container}

{elseif isset($child.thumbnail)}
<a href="{$linkUrl}">004
{g->image item=$child image=$child.thumbnail class="giThumbnail"}
</a>

{else}
...
...

{/if}
</div>

----

Thanks for your help !!!

Alessandro