Either PDF or PHP page

5 posts by 3 authors in: Forums > CMS Builder
Last Post: March 31, 2011   (RSS)

By degreesnorth - March 30, 2011

Hi

I was wondering whether there is a way to choose whether the listing link goes to a PHP page or whether it can also go to a PDF? Here's the scenario. We have a number of reviews, sometimes they will be in text where we can load them on the site as php content (ie, text fields). Yet other times, they will be available as pdfs only and it's too difficult to reproduce all (especially if it's a newspaper clipping).

1. We have a reviewslist.php page which will always have a blurb intro with regards to what the review is, ie, http://www.audiomarketing.com.au/reviewslist.php

2. This currently goes to http://www.audiomarketing.com.au/reviewsdetail.php (for example) which is text based. However, when there is no text available, and only a pdf, is there code which can say, "select whether the detail page should go to text or pdf?" OR "if there's text, then display text, and IF there is no text, then display the pdf?

Or is that asking too much? I need to automate this as much as possible.

Thanks

Re: [degreesnorth] Either PDF or PHP page

By Toledoh - March 31, 2011

I normally have a field called "link type" that is a radio button with options as "internal", "external", "file".

Then I do an few if statments;
<?php if ($record['link_type'] == 'internal'): ?> ...your code...
<?php elseif ($record['link_type'] == 'external'): ?> ...your code...
<?php elseif ($record['link_type'] == 'file'): ?> ...your code...
<?php endif ?>
<?php endforeach; ?>

Cheers,

Tim (toledoh.com.au)

Re: [Toledoh] Either PDF or PHP page

By degreesnorth - March 31, 2011

Hi Tim
Thanks for your reply. I'm a bit stuck about the third option ('file'). Is that meant to open the pdf file? Could you clarify please.
Cheers
Carole

Re: [degreesnorth] Either PDF or PHP page

By Toledoh - March 31, 2011

Try this;
<?php if ($record['link_type'] == 'internal'): ?>
<a href="<?php echo $record['link_field'] ?>">Link within site as a text field</a>
<?php elseif ($record['link_type'] == 'external'): ?>
<a href="<?php echo $record['link_field'] ?>" target="_blank">Link outside of site as a text field</a>
<?php elseif ($record['link_type'] == 'details'): ?>
<a href="<?php echo $record['_link'] ?>">This links to your details page</a>
<?php elseif ($record['link_type'] == 'file'): ?>
<?php foreach ($record['file'] as $upload): ?>
<a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br />
<?php endif ?>
<?php endif ?>
<?php endforeach; ?>


Hope it helps!
Cheers,

Tim (toledoh.com.au)