EllisLab text mark
Advanced Search
1 of 3
1
   
Download Content Plugin
Posted: 20 September 2011 04:36 PM   [ Ignore ]
Avatar
Joined: 2002-06-03
6432 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…

 
Posted: 21 September 2011 08:14 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2008-09-17
59 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.

 
Posted: 21 September 2011 09:47 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-15
12649 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

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

 
Posted: 21 September 2011 10:57 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Joined: 2008-09-17
59 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.

 
Posted: 21 September 2011 11:15 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2007-10-05
265 posts

It’s download_content not content_download.

 Signature 

Amphibian Design | @devot:ee | GitHub | Twitter | EE Pro Network

 
Posted: 21 September 2011 12:07 PM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Joined: 2008-09-17
59 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.  grin

 
Posted: 21 September 2011 12:14 PM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Avatar
Joined: 2002-06-03
6432 posts

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

 
Posted: 21 September 2011 01:32 PM   [ Ignore ]   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2008-02-28
2331 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.

 Signature 

Defeat is a state of mind; no one is ever defeated until defeat has been accepted as a reality.

 
Posted: 21 September 2011 01:36 PM   [ Ignore ]   [ # 8 ]   [ Rating: 0 ]
Avatar
Joined: 2002-06-03
6432 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.

 
Posted: 21 September 2011 01:49 PM   [ Ignore ]   [ # 9 ]   [ Rating: 0 ]
Avatar
Joined: 2008-02-28
2331 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!

 Signature 

Defeat is a state of mind; no one is ever defeated until defeat has been accepted as a reality.

 
Posted: 21 September 2011 01:53 PM   [ Ignore ]   [ # 10 ]   [ Rating: 0 ]
Avatar
Joined: 2002-06-03
6432 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.

 
Posted: 21 September 2011 02:16 PM   [ Ignore ]   [ # 11 ]   [ Rating: 0 ]
Avatar
Joined: 2008-02-28
2331 posts

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

 Signature 

Defeat is a state of mind; no one is ever defeated until defeat has been accepted as a reality.

 
Posted: 21 September 2011 05:15 PM   [ Ignore ]   [ # 12 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-15
12649 posts
silverdart - 21 September 2011 02:57 PM

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 wink

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

 
Posted: 04 November 2011 08:15 AM   [ Ignore ]   [ # 13 ]   [ Rating: 0 ]
Joined: 2010-09-17
442 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} 
 
Posted: 04 November 2011 08:35 AM   [ Ignore ]   [ # 14 ]   [ Rating: 0 ]
Joined: 2010-09-17
442 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?

<p>
 
Lorem ipsum dolor sit ametconsectetur adipisicing elitsed do eiusmod tempor incididunt ut labore et dolore magna aliquaUt enim ad minim veniamquis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequatDuis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariaturExcepteur sint occaecat cupidatat non proidentsunt in culpa qui officia deserunt mollit anim id est laborum</p

Should I strip the HTML first?

 
Posted: 04 November 2011 09:16 AM   [ Ignore ]   [ # 15 ]   [ Rating: 0 ]
Avatar
Joined: 2002-06-03
6432 posts

Can you share your new EE code that you’re using?  Your first example doesn’t output CSV formatted content, just two fields with a line break in-between them.

 
1 of 3
1