close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Making document title a link to actual document

Thread began 4/20/2010 11:55 am by cnandrews291194 | Last modified 4/23/2010 12:11 pm by Eric Mittman | 1809 views | 5 replies |

cnandrews291194

Making document title a link to actual document

Howdy -

First, great job to WA on the integration between the DataAssist and Digital File Pro extensions - they've been great to work with, and save me a ton of work.

I've created a very simple document-management page that enables users to upload a file (.xls, .doc, .pdf, etc.) into a table. I'd like to have the Results page not only show the contents of the upload table, but to enable the document title as a link that would open the document (opening the 'Open with...' dialog that we all know and love).

I'm not much of a programmer, so please don't assume too much.

Thanks in advance --

cnandrews

Sign in to reply to this post

Eric Mittman

Have you tried applying the download server behavior to your results page? The server behavior is pretty simple, you tell it where the file is and what file to download and when the trigger occurs it will attempt to download that file from the location specified. Weather the user opens or saves the file will depend on how they have their browser setup, but this will initiate the process.

I would suggest that you add it to a test page first to get an idea of how it works. If you want to include it on your results page you would need to decide how you want things to work first.

If you know the page is secure and you just need that specific file to download you can add the file name as a parameter to the link that the user clicks on, then use this parameter in the download server behavior for the file name. The link might look like this:

<a href="results.php?filename=<the name of the file>">the link</a>

Then in the Download server behavior you would use the lightning bolt icon to set the value for the file name like this:

php:
$_GET['filename']



Please post back with any questions that you have about any part of this.

Sign in to reply to this post

cnandrews291194

Further clarification

Hi Eric -

I appreciate your reply, and have tried the behavior, but no dice. I'm attaching the page this displays on, and the code below.

As you can see from the browser page, the row repeat is fine, etc. - the problem now is that each of the documents repeats on each row of the table.

Ideas?

Thanks,
Charles

content.php

<?php require_once('../Connections/CMM.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$maxRows_DOCUMENTS = 10;
$pageNum_DOCUMENTS = 0;
if (isset($_GET['pageNum_DOCUMENTS'])) {
$pageNum_DOCUMENTS = $_GET['pageNum_DOCUMENTS'];
}
$startRow_DOCUMENTS = $pageNum_DOCUMENTS * $maxRows_DOCUMENTS;

mysql_select_db($database_CMM, $CMM);
$query_DOCUMENTS = "SELECT * FROM DOC_UPLOADS";
$query_limit_DOCUMENTS = sprintf("%s LIMIT %d, %d", $query_DOCUMENTS, $startRow_DOCUMENTS, $maxRows_DOCUMENTS);
$DOCUMENTS = mysql_query($query_limit_DOCUMENTS, $CMM) or die(mysql_error());
$row_DOCUMENTS = mysql_fetch_assoc($DOCUMENTS);

if (isset($_GET['totalRows_DOCUMENTS'])) {
$totalRows_DOCUMENTS = $_GET['totalRows_DOCUMENTS'];
} else {
$all_DOCUMENTS = mysql_query($query_DOCUMENTS);
$totalRows_DOCUMENTS = mysql_num_rows($all_DOCUMENTS);
}
$totalPages_DOCUMENTS = ceil($totalRows_DOCUMENTS/$maxRows_DOCUMENTS)-1;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Table Content</title>
<style type="text/css">
<!--
.SMALL_TEXT {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: .8em;
line-height: 2em;
}
-->
</style>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
<table width="100%" class="SMALL_TEXT">
<tr>
<td>DOCUMENT NAME</td>
<td>DOCUMENT</td>
<td>UPLOAD DATE</td>
<td>FIRST NAME</td>
<td>LAST NAME</td>
<td>DEPARTMENT</td>
<td>CATEGORY</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_DOCUMENTS['DOCNAME']; ?></td>
<td><?
$path = "UPLOADED DOCUMENTS";
$dir_handle = @opendir($path) or die("Unable to open $path");
echo "Directory Listing of $path<br/>";
while($file = readdir($dir_handle)) {
if(is_dir($file)) {
continue;
}

else if($file != '.' && $file != '..') {
echo "<a href='plugins/$path/$file'>$file</a><br/>";
}
}
//closing the directory
closedir($dir_handle);
?></td>
<td><?php echo $row_DOCUMENTS['UPLOAD_DATE']; ?></td>
<td><?php echo $row_DOCUMENTS['FNAME']; ?></td>
<td><?php echo $row_DOCUMENTS['LNAME']; ?></td>
<td><?php echo $row_DOCUMENTS['DEPARTMENT']; ?></td>
<td><?php echo $row_DOCUMENTS['CATEGORY']; ?></td>
</tr>
<?php } while ($row_DOCUMENTS = mysql_fetch_assoc($DOCUMENTS)); ?>
</table>
</form>
</body>
</html>
<?php
mysql_free_result($DOCUMENTS);
?>

Sign in to reply to this post

Eric Mittman

It looks like your loop is occurring for each row that you have. The reason you have the same entries for each row is because the you are looping over the directory contents for each row.

I'm including an example of how a page like this could be setup using a recordset, repeat region, and a separate download page based on the link from the results page. Please check these out to get an idea for how you could setup the listing and download pages.

When I created the results page I just added a recordset to select all of the records in my uploads table. Next I added the file name binding to the page to display it. I then added the link to the download page around the bindings. Next I added in the "?file=<?php echo $row_Recordset1['filename']; ?> to the url in the link. The last part was to select the display that I crafted and apply the repeat region to it. This made it show an entry for each record in my db.

Then on the download page I added the download server behavior, selected the directory and for the file name I set it to this:

php:
<?php $_GET['file'?>



Please post back with any questions that you have about this.

Attached Files
download.zip
Sign in to reply to this post

cnandrews291194

cornrows pcal

Eric -

Great details - I really appreciate your help.

I'll give this a shot this weekend and let you know.

Thanks again,
Charles

Sign in to reply to this post

Eric Mittman

Sounds good, I definitely think this is the cleanest and easiest way to get this type of download setup. Let us know if you have any questions about any part of it.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...