Single link, filetype or article

2 posts by 2 authors in: Forums > CMS Builder
Last Post: January 12, 2009   (RSS)

By eriqcook - January 12, 2009 - edited: January 12, 2009

Sorry to repost this people but I am rephrasing my question in an attempt to make it more clear as to what I need.

[font "Verdana"]I would like to show a single link, called "View", which displays an article by clicking on the link (and opens the article in a web page) if the record is an article, OR displays a file (PDF, Word doc, etc) if the file is an upload type.

[font "Verdana"]I've been playing around with the code all weekend and just can't figure it out. If you take a look at the following link:

[url "http://www.interactivetools.com/forum/forum.cgi?url=http%3A%2F%2Fwww.mtrip.org%2Fv2%2Fcmstest.php"][font "Verdana"]http://www.mtrip.org/v2/cmstest.php[/#333366][/url][font "Verdana"]

[font "Verdana"]Notice the two links at the bottom of each record: "View/Download Page" and "View/Download File"? A typical [font "Verdana"]record will only be one or the other (article or file upload). Not both. This is the problem: I only want to display ONE link, and depending on the type of record it is (file upload or standard article), load the appropriate viewer (for web page) or just open the file (PDF, Word doc, etc). I don't want to display both links. I just want to system to do the corresponding action based on the type of file it is.

[font "Verdana"]Is this possible? I think it involves some IF/ELSE coding, but I'm clueless on how to do that.

[font "Verdana"]Here's the code I'm currently using:

<a href="<?php echo $record['_link'] ?>">View Web Page</a> (if applicable)<br/>
<!-- STEP 2a: Display Uploads for field 'file' (Paste this anywhere inside STEP2 to display uploads) -->
<!-- Upload Fields: num, createdTime, tableName, fieldName, recordNum, preSaveTempId, filePath, filename, extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
<?php foreach ($record['file'] as $upload): ?><br/>
<?php else: ?><a href="<?php echo $upload['urlPath'] ?>">View/Download<br /></a>
<?php endif ?>
<?php endforeach ?>

[font "Verdana"]How do I code the page in order to do that? hope I explained it easier.

[font "Verdana"]Thank you...