List & Detail - linking to an external file

3 posts by 2 authors in: Forums > CMS Builder
Last Post: September 28, 2008   (RSS)

Re: [rsekaly] List & Detail - linking to an external file

One way would be to create a new field in your section to handle the external file link rather than putting it in the content section. Then, in your list page, use a conditional statement to determine exactly which field from your section is going to be used as the link.

Example:

Add a textfield to your section. Title it, for example, external_link. Now, in the record where you want to link to a pdf rather than move to a detail page, instead of placing any content in the content field, place the link url into the external_link field. Then save it.

In your list page code, right after the line <?php foreach ($xxxxxRecords as $record): ?>, add the following code:

<?php if ( !empty($record['external_link']) ) {
$new_link = $record['external_link'];
} else {
$new_link = $record['_link'];
} ?>


Then, where your code declares the url that should be used as the link, change:

<a href="<?php echo $record['_link'] ?>">

to:

<a href="<?php echo $new_link ?>">

Then, when you browse to your list page, the code will check to see if the new external_link field has something in it. If it does, then it will now use what's in that field for the link.

Hope this helps somewhat.

Jim
WebCamp One, LLC



Websites That Work

Re: [Mr Jim] List & Detail - linking to an external file

That's great!

Thanx a lot Jim, it worked perfectly.
--
Ragi Sekaly

"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke