Linking an Image to a PDF ?

9 posts by 4 authors in: Forums > CMS Builder
Last Post: June 23, 2010   (RSS)

By Chris_t - February 22, 2008

Hello All,

Just want to say thanks to all your help.
The site is live now http://www.ragefootball.com and about 90% was made with the help of CMS Builder. There are some pages that still need to be done. One such page will be a page for kids to download/open a PDF and print it out to be colored. Now I know in the admin part I can add pdf as a file type that can be uploaded but to link it to a thumbnail I assume I will need a separate jpg for that unless CMS can make one from a pdf. So other than making the field a wysiwyg and doing it the html way by placing an image then linking it to the file. Can it be done with just upload boxes ?

Thanks
Chris

Re: [ChrisTitchenal] Linking an Image to a PDF ?

By Dave - February 22, 2008

Hi Chris,

No, unfortunately there is no automatic thumbnailing for PDFs. I did a quick search and I couldn't find any well supported or built-in PHP function that did that either.

Some options:

You can upload PDFs through the wysiwyg and link them. You'd click the image button, upload an image, then highlight it, click the link button and upload your PDF.

Without using the wysiwyg you could have a section for coloring pages, with an upload field for thumbnail and PDF, each allowing only one upload and then link them together with some PHP.

Or, you could just have text links or the same icon for each (not very much fun I know).

Would any of those work for you?
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Linking an Image to a PDF ?

By Chris_t - February 22, 2008

Hey Dave,

Yeah I was thinking I would need to go with a wysiwyg. My only problem is out of the staff that keeps the site updated, maybe 2 would know how to do that. Lets hope this page hardly gets updated. Thanks for your help

I thought of another question this is for another site we are going to use cms for. They will be listing locations and want to have the address link to mapquest or google maps. I know listing manager did that atomically. So how would I have a link that says "click here for a map" and have the fields pulled from the entered data.

Thanks again

Chris

Re: [ChrisTitchenal] Linking an Image to a PDF ?

By Dave - February 22, 2008

For linking to a map sites (or any site that takes input) here's what you do:

You go to the site (let's use Google Maps) and search for an address. I'll search for our office address: 2730 Commercial Drive, Vancouver, BC, Canada.

With Google I click "Link to this Page" and I get a long link like this:

http://maps.google.com/maps?f=q&hl=en&geocode=&q=2730+Commercial+Drive,+Vancouver,+BC,+Canada&
sll=49.250899,-122.939304&sspn=0.010533,0.019548&ie=UTF8&z=16&iwloc=addr

I see how much I can remove and still have the link work. I get this:

http://maps.google.com/maps?q=2730+Commercial+Drive,Vancouver,BC,Canada

So I just replace the values with PHP tags, like this:

http://maps.google.com/maps?q=<?php echo $record['address']; ?>,<?php echo $record['city']; ?>,<?php echo $record['state']; ?>,<?php echo $record['country']; ?>

Except because it's an url you need to "url encode" so spaces get converted to + and so on. So we use the PHP urlencode() function like this:

http://maps.google.com/maps?q=<?php echo urlencode($record['address']); ?>,<?php echo urlencode($record['city']); ?>,<?php echo urlencode($record['state']); ?>,<?php echo urlencode($record['country']); ?>

And there's your link. You can use that process to automatically create links to map sites passing an address, amazon.com passing a product name, or many other sites.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [kkegans] Linking an Image to a PDF ?

By Jason - June 23, 2010

Hi,

So what you need is when a user clicks on the image, they are linked to a pdf. Is that right?

We can definitely do this, if you can attach the file furniture_portfolio.php to this thread, I can take a look and give you some more specific directions.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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

Re: [Jason] Linking an Image to a PDF ?

By kkegans - June 23, 2010

Jason,

I would like the Uploaded PDF file to be linked to both the 'Upload" Image and the 'Client' Name

The attached php file only includes the client data and the upload image, as I am not clear on the best method of uploading the associated PDF file, as a seperate upload field or a second file in the same upload field as the image?



Thanks,
CMSB Rocks!



Thanks,



Kurt
Attachments:

furniture_portfolio.php 6K

Re: [kkegans] Linking an Image to a PDF ?

By Jason - June 23, 2010

Hi,

If you're uploading your PDF to the Image field and you want that pdf to be linked to both by clicking on the image or by clicking on the Client Name, you can try using this code:

<?php foreach ($portfolio_contentRecords as $record): ?>

<?php $pdf="";?>
<?php foreach($record['image'] as $upload): ?>
<?php if($upload['extension']=="pdf"):?>
<?php $pdf=$upload['urlPath']; ?>
<?php endif ?>
<?php endforeach ?>
<tr>
<td class="pict"><?php foreach ($record['image'] as $upload): ?>
<?php ($upload['hasThumbnail']) ?>
<a href="<?php echo $pdf ?>" title="<?php echo $record['client'] ?> profile" target="_blank">
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /></a>
<?php endforeach ?></td>
<td class="client">


<a href="<?php echo $pdf ?>" title="<?php echo $record['client'] ?> profile" target="_self"><?php echo $record['client'] ?></a><br />
<span class="smaller"><?php echo $record['location'] ?></span>
</td>
</tr>
<?php endforeach ?>


This will find the pdf file in the uploads and store the urlPath of that upload in a variable called $pdf. This will then be used as the url for the two links.

Note: If you upload more than one pdf to the images field for a single record, it will use the last one in the list.

Give this a try and let me know if you run into any issues.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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

Re: [Jason] Linking an Image to a PDF ?

By kkegans - June 23, 2010

Jason,



Worked like a champ - THANK YOU!!!!!!

Kurt
CMSB Rocks!



Thanks,



Kurt