Jump to content

PDF icon in "Download" tab?


Recommended Posts

We did this on our shop. What we did was:

In product.tpl under the line 

{foreach from=$attachments item=attachment}

We added :

{if ($attachment.mime == "application/pdf")} class="pdf" {/if}

to the "a" tag of the PDF.

Then, in product.css we added this code:
 

a.pdf {
background:url(../img/pdf_icon.png) 0 0 no-repeat;
padding:0 0 0 22px !important;
}

With the png just being a 16x16 PDF icon we made and placed in the theme img folder.

Edited by AnonymousUser (see edit history)
Link to comment
Share on other sites

Hmmm... can't get this to work.  Thinking it may be my placement of the a.pdf tag in the .css file.

 

Knowing now where this code is tho, I also then tried to hardcode an IMG tag to always show a pdf icon, but that shows a broken image icon.  I believe it's finding the image file though because if I change the image path to intentionally point to something invalid, it shows a "?" icon.

Link to comment
Share on other sites

Hmmm... can't get this to work.  Thinking it may be my placement of the a.pdf tag in the .css file.

 

Knowing now where this code is tho, I also then tried to hardcode an IMG tag to always show a pdf icon, but that shows a broken image icon.  I believe it's finding the image file though because if I change the image path to intentionally point to something invalid, it shows a "?" icon.

It may be a CSS specificity issue. May try and see if something like "#product a.pdf" works as your CSS selector. 

Link to comment
Share on other sites

So I've not been able to figure this out with CSS, but hardcoded it for now... essentially just using an img tag.  However, I'll probably attach docs other than pdf in the future so I'd like to figure it out.

 

It did not seem to be recognizing the pdf mime type, so I thought I'd try to detect the ".pdf" extension.  I just don't know enough (or any smarty yet), so I'll go read up on that first. ;)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...