[SOLVED] View Page, No Download | View Page, Download
[SOLVED] View Page, No Download | View Page, Download
I'm running the latest version of CMSMS... fully up-to-date Red Hat and MySQL. All is running perfectly.
Here's what I'd like to do:
1) Public user visits a page on the site. Sees list of files in a table format: Product Number, Product Name, PDF Download 1, PDF Download 2
2) User can see that there are downloadable files, but can't download them.
Then...
1) User gets username and password logs in to the page.
2) Once logged in, the registered user can see the same list, but now CAN download the PDFs.
Is this possible within the current structure? Or by using any of the modules? Any direction is highly appreciated. Let me know if you need further clarification. Thanks!
Jeff T.
Here's what I'd like to do:
1) Public user visits a page on the site. Sees list of files in a table format: Product Number, Product Name, PDF Download 1, PDF Download 2
2) User can see that there are downloadable files, but can't download them.
Then...
1) User gets username and password logs in to the page.
2) Once logged in, the registered user can see the same list, but now CAN download the PDFs.
Is this possible within the current structure? Or by using any of the modules? Any direction is highly appreciated. Let me know if you need further clarification. Thanks!
Jeff T.
Last edited by jtcreate on Fri Jul 11, 2008 11:12 am, edited 1 time in total.
Mmmmm... Tasty.
Re: View Page, No Download | View Page, Download
Yes, with the Frontend Users/Custom Content modules you could have:
{if $ccuser->loggedin()}
table with download links
{else}
table without download links
{/if}
Nullig
{if $ccuser->loggedin()}
table with download links
{else}
table without download links
{/if}
Nullig
Re: View Page, No Download | View Page, Download
Good idea. Thanks.
I would, however, have to have two full tables, correct? No way to have one set of data and just {else} {/if} the links?
I appreciate your help.
I would, however, have to have two full tables, correct? No way to have one set of data and just {else} {/if} the links?
I appreciate your help.
Mmmmm... Tasty.
Re: View Page, No Download | View Page, Download
You could have your table and put the links within {if} ... {else} ... {/if}, but, with a large table, you'd have a lot of them like:
{if $ccuser->loggedin()}
linked text
{else}
unlinked text
{/if}
Where are you pulling the table data from? or are you just hard coding it?
Nullig
{if $ccuser->loggedin()}
linked text
{else}
unlinked text
{/if}
Where are you pulling the table data from? or are you just hard coding it?
Nullig
Last edited by Nullig on Wed Jul 09, 2008 7:14 pm, edited 1 time in total.
Re: View Page, No Download | View Page, Download
That's the trick... I need to have it so my customer can edit/add as needed through the WYSIWYG interface (ideally).
Jeff T.
Jeff T.
Mmmmm... Tasty.
Re: View Page, No Download | View Page, Download
Why not have them upload to a specific directory, then pull the info automatically using a UDT?
Nullig
Nullig
Re: View Page, No Download | View Page, Download
That sounds great. Can you elaborate on the specifics? I'm assuming we'd need some PHP that examines the directory, pulls the filename, adds the else/ifs and then it gets 'printed' to the page.
This is a smidge beyond my PHP skills...
Thanks,
Jeff T.
This is a smidge beyond my PHP skills...
Thanks,
Jeff T.
Mmmmm... Tasty.
Re: View Page, No Download | View Page, Download
Something like this (untested)...
Assuming files names like ###-Product name.pdf in the directory /uploads/products/ - adjust according to your needs.
Create a UDT called "productfiles" (without the quotes) and use this code:
Then use the tag like this:
Nullig
Assuming files names like ###-Product name.pdf in the directory /uploads/products/ - adjust according to your needs.
Create a UDT called "productfiles" (without the quotes) and use this code:
Code: Select all
global $gCms;
echo "<table>";
echo "<tr>";
echo "<th>Product Number</th>";
echo "<th>Product Name</th>";
echo "<th>Document</th>";
echo "</tr>";
$dir = "uploads/products/";
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$products = explode("-", $file);
$products2 = explode(".", $products[1]);
echo "<tr>";
echo "<td>$products[0]</td>";
echo "<td>$products2[0]</td>";
if ($params['linked']=='true') {
echo "<td><a href='$dir$file' target='_blank'>$file</a></td>";
} else {
echo "<td>$file</td>";
}
echo "</tr>";
}
}
closedir($handle);
}
}
}
echo "</table>";
Code: Select all
{if $ccuser->loggedin()}
{productfiles linked='true'}
{else}
{productfiles linked='false'}
{/if}
Last edited by Nullig on Wed Jul 09, 2008 8:12 pm, edited 1 time in total.
Re: View Page, No Download | View Page, Download
Nice. I'll be working on this later today and tomorrow and will report back as to how it went. Thank you very much.
Jeff T.
Jeff T.
Mmmmm... Tasty.
Re: View Page, No Download | View Page, Download
Tested it myself and made a couple of changes. Recopy the code from the previous post. It will work better.
Nullig
Nullig
Re: View Page, No Download | View Page, Download
You could also add:
to the end of the UDT.
Nullig
Code: Select all
if ($params['linked']=='false') {
echo "<p>You must be logged in to download these documents.</p>";
}
Nullig
Re: View Page, No Download | View Page, Download
Nullig,
This works absolutely great! I can't thank you enough.
One final question... I wasn't clear on how to properly name the second PDF that would end up in the same line. When I add multiple files to the uploads/products folder, they show up on separate lines (which is good, if they're different products).
Thanks again. You've really saved the day.
Jeff T.
This works absolutely great! I can't thank you enough.
One final question... I wasn't clear on how to properly name the second PDF that would end up in the same line. When I add multiple files to the uploads/products folder, they show up on separate lines (which is good, if they're different products).
Thanks again. You've really saved the day.
Jeff T.
Mmmmm... Tasty.
Re: View Page, No Download | View Page, Download
How do you name the files now?
In order to parse the filename to extract the info you want to add to the table, you need to have the product number, product name and an id or number to differentiate the two documents.
If you used a naming convention like ###-Product Name-#.pdf, the script could be easily modified to strip out the info and post it properly.
Nullig
In order to parse the filename to extract the info you want to add to the table, you need to have the product number, product name and an id or number to differentiate the two documents.
If you used a naming convention like ###-Product Name-#.pdf, the script could be easily modified to strip out the info and post it properly.
Nullig
Re: View Page, No Download | View Page, Download
The files will be adjusted to fit our naming scheme. So, ###-Product Name-A.pdf for one and ###-Product Name-B.pdf for the other would work great.
So, in the end the table would look like this:
Prod Number | Prod Name | Doc 1(A) | Doc 2(B)
Some may only have one or the other, but all will most likely have both. Would you be up for one last tweak to the script? I think we'd be all set after this. Again, thank you.
Jeff T.
So, in the end the table would look like this:
Prod Number | Prod Name | Doc 1(A) | Doc 2(B)
Some may only have one or the other, but all will most likely have both. Would you be up for one last tweak to the script? I think we'd be all set after this. Again, thank you.
Jeff T.
Mmmmm... Tasty.