How to show the current PDF - for like a newsletter

Permalink
IDEA/CONCEPT/THEORY: Do you have a newsletter in a PDF that you would like to display online?
DEPENDENCY - You will need the "Simple PHP Block" Add-on installed first to do this:
http://www.concrete5.org/marketplace/addons/simple-php-block/...
Caveat to this is that your users maybe prompted for page coming from secure page

There maybe other resources to do this too and I am open to suggestions, etc.

RESOURCES USED:
Good information here. This is where base of this comes from
http://www.concrete5.org/community/forums/customizing_c5/get_files_...
Good info about file sorts, etc.
http://www.concrete5.org/marketplace/addons/list-files-from-set/...
How do I show just one file from a set? This limits the results to show just one record
http://stackoverflow.com/questions/1656969/php-limit-foreach-statem...
Loader::model("file_set");
Loader::model('file_list');
$fs = FileSet::getByName('My File Set');
$fl = new FileList();
$fl->filterBySet($fs);
$fl->sortByFileSetDisplayOrder($gs);
$files = $fl->get();
//CHANGE SORT ORDER? Comment out the next line to show the first file in set
$files = array_reverse($files);
//It is possible to do this by Date, Title, etc. but willl do this by set
$i=0;
foreach($files as $f) if ($i < 1) {
    $url = View::url('/download_file/view_inline', $f->getFileID(),$cID);
    $url = 'http://docs.google.com/viewer?url=' . urlencode(BASE_URL . DIR_REL . $url);
    echo "<p><h1>CURRENT ISSUE OF OUR NEWSLETTER</h1>";


Works pretty slick.

Thanks,

Kent
kdyer
View Replies:
kdyer replied on at Permalink Reply
kdyer
Ran into an issue with IE. IE does not like Google Viewer, or Zoho Viewer for that matter in an IFRAME. You will probably want to do the following, but does require that the user have a PDF reader installed.
Loader::model("file_set");
Loader::model('file_list');
$fs = FileSet::getByName('My File Set');
$fl = new FileList();
$fl->filterBySet($fs);
$fl->sortByFileSetDisplayOrder($gs);
$files = $fl->get();
//Comment out the next line to show the first file
$files = array_reverse($files);
//It is possible to do this by Date, Title, etc. but willl do this by set
$i=0;
foreach($files as $f) if ($i < 1) {
    $url = View::url('/download_file/view_inline', $f->getFileID(),$cID);
    echo "<h1>CURRENT NEWSLETTER</h1>";
    echo "<iframe src=" . BASE_URL . DIR_REL . $url . " width=100% height=780></iframe>";


Thanks,

Kent