Uploading documents for download
10 posts by 2 authors in: Forums > CMS Builder
Last Post: May 9, 2010 (RSS)
By svsanchez - May 5, 2010
I created an html file showing how it should look here: http://www.observatoriodsan.org/dummy.htm
Can you tell me how to do this please!
Thank you!
www.deguate.com
Re: [svsanchez] Uploading documents for download
By gkornbluth - May 5, 2010 - edited: May 5, 2010
Working with uploads is easier than you probably think they are at this point.
Here’s the basic process, modified from some of the recipes in my CMSB Cookbook http://www.thecmsbcookbook.com
First, in the admin > section editor area of your CMSB interface, click on “create new menu” to create a multi-record editor called PDF to store the information about your pdf files.
You’ll need at least three fields in this editor.
A “title” text field for the link
A “content” text box for the description
And an “upload” field for the actual pdf file
For now it will be easier to use the existing "title" and "content" fields that were created by default. Just click "modify" to change the field type for “content” to a text box field and re-save it.
You’ll need to create a new field for the actual PDF upload and call that field PDF. You’ll want to change some of the values in the input validation area.
For now, delete all the file extensions allowed and type in "pdf" (lower case, no double quotes and no period before the extension) if you want to allow other types of documents, just add these extensions to the list, separated by commas.
Change the maximum uploads to 1
Change the maximum upload size to a more reasonable number, say 1000Kbytes
Uncheck the "resize" and "create thumbnail" boxes
Remove the words "title" and "caption" from the" info1" and "info2" fields and click "save" and then on "save details".
Then in the menu, click on the PDF editor you just created and then on “create” to create your first record and upload a test PDF (or other type of document).
Fill out the information for the title and content fields.
Save the record and create a second test record and save it as well.
Now go to the Admin > code generator, choose the PDF as the section and list page as the viewer type.
Leave everything else as it is and click on show code.
Copy the code before the "head" tag to your dummy html page, replacing everything before the "head" tag. and change the extension of the page to .php as in “dummy.php”
In the body, where you want to show the list of PDF files, insert the following code:
<?php foreach ($pdfRecords as $record): ?>
<?php foreach ($record['pdf'] as $upload): ?>
<a href="<?php echo $upload['urlPath'] ?>"> <?php echo $record['title'] ?></a><br />
<?php echo $record['content'] ?><br />
<?php endforeach ?>
<?php endforeach ?>
That should get you started.
You can style the page the same way that you would any html page using CSS.
After you get the hang of this, you can also change the image from the PDF image to other types of images using "IF statements".
Good luck.
Best,
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Uploading documents for download
By svsanchez - May 5, 2010
Notice: Undefined index: gestion_del_conocimiento in /home/observat/public_html/dummy.php on line 53 Warning: Invalid argument supplied for foreach() in /home/observat/public_html/dummy.php on line 53
Here's the link: http://www.observatoriodsan.org/dummy.php
www.deguate.com
Re: [svsanchez] Uploading documents for download
By gkornbluth - May 5, 2010
Let's start simple.
If you paste the entire code generator code into a blank test.php document does that work at all?
Jerry
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Uploading documents for download
By svsanchez - May 5, 2010
http://www.observatoriodsan.org/gestiondetail.php
www.deguate.com
Re: [svsanchez] Uploading documents for download
By gkornbluth - May 5, 2010 - edited: May 5, 2010
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Uploading documents for download
By svsanchez - May 5, 2010
www.deguate.com
Re: [svsanchez] Uploading documents for download
By gkornbluth - May 5, 2010
If you take a look at http://artistsofpalmbeachcounty.org/PDF_Test.php you'll see the result of following the instructions I offered above, copying the entire code generator code, followed by pasting in the body code in my suggestion. They both seem to work.
Check everything again and I'm sure that you'll find the discrepancy.
Good luck,
Don't get too discouraged.
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Uploading documents for download
By svsanchez - May 9, 2010
Now on the "if" statements to show a "PDF" icon, "Word" icon, etc... can you help me on doing that?
Thank you again!
www.deguate.com
Re: [svsanchez] Uploading documents for download
By gkornbluth - May 9, 2010 - edited: May 9, 2010
Glad it's working. WYSIWYG fields can be a bit tricky.
You could upload all the icons you want to use into a folder called “images” in your sites root directory.
Then, inside the upload foreach loop, where you want to show the icon, you could use something like the following:
<?php if ($upload['extension'] == 'pdf'): ?>
<img src="http://www.your_site/images/pdf.jpg" width="nn" height="xx" />
<?php if ($upload['extension'] == 'doc'): ?>
<img src="http://www.your_site/images/doc.jpg" width="nn" height="xx" />
<?php else: ?>
<img src="http://www.your_site/images/other_format.jpg" width="nn" height="xx" />
<?php endif ?>
Hope that gets you going.
Best,
Jerry Kornbluth
<?php if ($upload['extension'] == 'swf'): ?>
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php