Linking an Image to a PDF ?

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

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: [Dave] Linking an Image to a PDF ?

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: [Dave] Linking an Image to a PDF ?

By kkegans - June 22, 2010

Dave, I have a situation where I need to link a PDF to an image in a viewer page and can't figure out the PHP code to make it work. I have tried using separate uploads for the img and PDF, and also looked at using 1 upload field with a limit of 2 uploads (img and pdf).



I found this thread and you eluded to being able to use 2 upload fields one for the image and another for the pdf and linking them with some php. Would you give me a suggestion of what the php needs to look like for the display and linking?



The page I am working on is http://www.seagateop.com/furniture_portfolio.php and where the image and the client name is currently linked to the imageupload, I need to have them linked to a pdf file.



Thanks for your help!
CMSB Rocks!
Thanks,
Kurt

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