ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Download Content Plugin

September 20, 2011 4:36pm

Subscribe [10]
  • #1 / Sep 20, 2011 4:36pm

    Derek Jones's avatar

    Derek Jones

    7561 posts

    We just pushed a new, very simple free plugin to our GitHub accountDownload Content is handy if you are using channels to manage information that you want to have available as file downloads for your visitors.  It’s essentially a very simple way to utilize CodeIgniter’s download helper within an ExpressionEngine template.  It takes arbitrary content, and sends it to the browser with the proper file type headers for download.

    For example, we’re using it on our intranet to have… Continue reading…

  • #2 / Sep 21, 2011 8:14am

    silverdart

    46 posts

    Hi

    I may well be doing something dumb, but I have not been able to get the plugin to work - i get an ‘invalid tag (no such plugin..)’ warning in the template.  I have tried placing the pi.download_content.php file in the system/expressionengine/plugins folder, and also placing the download-content folder, containing the php file, in the system/expressionengine/third_party folder - neither works and the plugin does not show up in my plugins list in the CP in either case.

    I am on EE 2.1.3 - is that the problem?  I would be grateful for some advice. Thanks.

  • #3 / Sep 21, 2011 9:47am

    Mark Bowen's avatar

    Mark Bowen

    12637 posts

    I might be wrong but I believe the folder needs to be renamed to download_content instead of it being download-content.

    Also I believe the syntax for the plugin should be :

    {exp:download_content filename="foo.txt"}
    Some random content, maybe from a weblog tag.
    {/exp:download_content}

    Hopefully that should then get it working for you.

    Mark

  • #4 / Sep 21, 2011 10:57am

    silverdart

    46 posts

    Thanks, Mark

    Changing the folder name has worked, but only so far as the plugin is now appearing correctly in the plugins list in the CP. I am still getting this error when I try to view a template:

    Error
    The following tag has a syntax error:
    {exp:content_download}
    Please correct the syntax in your template

    The tag is on a blank template, for testing purposes, with just the following code:

    {exp:channel:entries channel="about" entry_id="65"}
    {exp:content_download filename="{title}.txt"}
    {summary}
    {/exp:content_download}
    {/exp:channel:entries}

    The summary field is text. I would be grateful for any further thoughts. Many thanks.

  • #5 / Sep 21, 2011 11:15am

    Derek Hogue's avatar

    Derek Hogue

    316 posts

    It’s download_content not content_download.

  • #6 / Sep 21, 2011 12:07pm

    silverdart

    46 posts

    Thanks, Derek - you are so right!!

    I felt v stupid until I remembered that I had copied and pasted the original code from the github php file - I went to check, and sure enough the ‘content_download’ sample code is right there, and of course, as a result, it appears like that on the CP in the plugin section.

    I normally think that EllisLab are geniuses at everything, but on this occasion I think they might have let a couple of things slip by - first, the folder name for this plugin and second the sample code. I should have spotted that, of course - but at least someone out there in the EE community has sharp eyes. I guess someone should fix that.

    Many thanks indeed - it now seems to be working as intended and will be useful - and I still love EllisLab, by the way.  😊

  • #7 / Sep 21, 2011 12:14pm

    Derek Jones's avatar

    Derek Jones

    7561 posts

    Thanks Derek and silverdart, both the folder name in the repo and the sample code have been fixed.

  • #8 / Sep 21, 2011 1:32pm

    lebisol's avatar

    lebisol

    2234 posts

    Any limitations to what file type can be generated?
    First usage that comes to mind is creating PDFs out of channel content.
    Thank you.

  • #9 / Sep 21, 2011 1:36pm

    Derek Jones's avatar

    Derek Jones

    7561 posts

    It would essentially be limited to file types that you can “hand roll” since you are building the file itself in your template with your template code and channel content.

  • #10 / Sep 21, 2011 1:49pm

    lebisol's avatar

    lebisol

    2234 posts

    So I imagine just flat files and no compressed zip/rar if we pull multiple entries from channels?
    Could we put together a list of file ext?
    html,htm,xml,css,txt…???

    Thanks!

  • #11 / Sep 21, 2011 1:53pm

    Derek Jones's avatar

    Derek Jones

    7561 posts

    Well, even that would be possible, if you combined with another plugin - one that took the content and zipped it, for instance, though I’d think that such a plugin would probably also include the download mechanism, removing the need for two separate plugin tags.  This plugin is really very simple - any content between the tag pairs is sent to the browser as a download.  How you build that content and what format it is in is entirely up to you.

    It would be very difficult even to list every file extension that you could hand roll without any extra processing, as there are so many.  vcf, ics, csv, and so on.

  • #12 / Sep 21, 2011 2:16pm

    lebisol's avatar

    lebisol

    2234 posts

    Fair enough, thanks D.
    VCF and CSV are definitely hot items so this is very cool little plugin.

  • #13 / Sep 21, 2011 5:15pm

    Mark Bowen's avatar

    Mark Bowen

    12637 posts

    Thanks, Mark

    Changing the folder name has worked, but only so far as the plugin is now appearing correctly in the plugins list in the CP. I am still getting this error when I try to view a template:

    I did actually post the correct syntax above 😉

  • #14 / Nov 04, 2011 8:15am

    bgarrant

    356 posts

    How can I get this to format correct when trying to export channel entries to a CSV?  I have tried this code but it is breaking up results incorrectly in cells when I open in Excel.  Just trying to export two fields with this test. simple_content_body is a long string with about 300 characters.

    {exp:download_content filename="foo.csv"}
    {exp:channel:entries channel="pages" disable="categories|member_data|pagination" dynamic="no"}
    {title}
    {simple_content_body}
    {/exp:channel:entries}
    {/exp:download_content}
  • #15 / Nov 04, 2011 8:35am

    bgarrant

    356 posts

    OK a short string works fine it seems, but when a longer string is used it causes the lines to break up.  Why would this string not work?  Is there a character limit or something or is the paragraph tag the issue?

    
     Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum

    Should I strip the HTML first?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases