Load an icon up only if a file has been loaded up

5 posts by 2 authors in: Forums > CMS Builder
Last Post: April 11, 2014   (RSS)

By MercerDesign - April 8, 2014

This is quite hard to explain, I want to be show an icon for a pdf, a word document or a link to webpage. I want it to only show if a file has been added to the CMS entry. So if there is nothing loaded up then the icon disappears. I ahev done something similar before but cannot work out how I have done it.

By Damon - April 9, 2014

Hi,

You can use the file extension code to determine what the file type is:

<?php echo $upload['extension'] ?>

Then either you an if statement (if pdf display pdf icon) or you could control the icons using CSS:

... class="<?php echo $upload['extension'] ?>

Let me know what method you want to go with and I can provide more details.

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By MercerDesign - April 10, 2014

I tried the fle extension option but I obviously wasn't doing it properly, could you give me instructions for both methods for me to try again please.

Thanks for your help.

By Damon - April 11, 2014

Hi,

Take a look at this tutorial with icon and code examples:

http://askthecssguy.com/articles/showing-hyperlink-cues-with-css/

CSS like this should get the results I think you are after:

a[href^="http:"] {    
    display:inline-block;    
    padding-right:14px;    
    background:transparent url(/Images/ExternalLink.gif) center right no-repeat;
}

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/