Memorial Day
Support will be closed on Monday, May 28th, 2012 to enjoy Memorial Day with our friends and families.
   
1 of 3
1
Download Content Plugin
Posted: 20 September 2011 03:36 PM   [ Ignore ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  11303
Joined  06-03-2002

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…

 Signature 
Profile
MSG
 
 
Posted: 21 September 2011 07:14 AM   [ Ignore ]   [ # 1 ]  
Grad Student
Rank
Total Posts:  63
Joined  09-17-2008

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.

Profile
 
 
Posted: 21 September 2011 08:47 AM   [ Ignore ]   [ # 2 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  13771
Joined  04-15-2006

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

Profile
 
 
Posted: 21 September 2011 09:57 AM   [ Ignore ]   [ # 3 ]  
Grad Student
Rank
Total Posts:  63
Joined  09-17-2008

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.

Profile
 
 
Posted: 21 September 2011 10:15 AM   [ Ignore ]   [ # 4 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  297
Joined  10-05-2007

It’s download_content not content_download.

 Signature 

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

Profile
 
 
Posted: 21 September 2011 11:07 AM   [ Ignore ]   [ # 5 ]  
Grad Student
Rank
Total Posts:  63
Joined  09-17-2008

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

Profile
 
 
Posted: 21 September 2011 11:14 AM   [ Ignore ]   [ # 6 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  11303
Joined  06-03-2002

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

 Signature 
Profile
MSG
 
 
Posted: 21 September 2011 12:32 PM   [ Ignore ]   [ # 7 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2544
Joined  02-28-2008

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.

Profile
 
 
Posted: 21 September 2011 12:36 PM   [ Ignore ]   [ # 8 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  11303
Joined  06-03-2002

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.

 Signature 
Profile
MSG
 
 
Posted: 21 September 2011 12:49 PM   [ Ignore ]   [ # 9 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2544
Joined  02-28-2008

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.

Profile
 
 
Posted: 21 September 2011 12:53 PM   [ Ignore ]   [ # 10 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  11303
Joined  06-03-2002

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.

 Signature 
Profile
MSG
 
 
Posted: 21 September 2011 01:16 PM   [ Ignore ]   [ # 11 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2544
Joined  02-28-2008

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.

Profile
 
 
Posted: 21 September 2011 04:15 PM   [ Ignore ]   [ # 12 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  13771
Joined  04-15-2006
silverdart - 21 September 2011 01: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

Profile
 
 
Posted: 04 November 2011 07:15 AM   [ Ignore ]   [ # 13 ]  
Research Assistant
RankRankRank
Total Posts:  432
Joined  09-17-2010

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} 
Profile
 
 
Posted: 04 November 2011 07:35 AM   [ Ignore ]   [ # 14 ]  
Research Assistant
RankRankRank
Total Posts:  432
Joined  09-17-2010

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?

Profile
 
 
Posted: 04 November 2011 08:16 AM   [ Ignore ]   [ # 15 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  11303
Joined  06-03-2002

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.

 Signature 
Profile
MSG
 
 
Posted: 04 November 2011 08:21 AM   [ Ignore ]   [ # 16 ]  
Research Assistant
RankRankRank
Total Posts:  432
Joined  09-17-2010
Derek Jones - 04 November 2011 08:16 AM

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.

I am trying this right now David:

{exp:download_content filename="foo.csv"}
{exp
:channel:entries channel="pages" disable="categories|member_data|pagination" dynamic="no"}
{exp
:strip_html}
Title
URL TitleEntry IDBody
{title}
{url_title}{entry_id}{simple_content_body}
{
/exp:strip_html}
{
/exp:channel:entries}
{
/exp:download_content} 

There are two entries in this channel at moment, but there will be a lot more.  The simple_content_body is the only one with a long string.  It has HTML tags in it so I tried stripping it first but no luck.  Can I sent you the generated CSV file?

Profile
 
 
Posted: 04 November 2011 08:22 AM   [ Ignore ]   [ # 17 ]  
Research Assistant
RankRankRank
Total Posts:  432
Joined  09-17-2010
Derek Jones - 04 November 2011 08:16 AM

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.

I took out label row and still no luck.

{exp:download_content filename="foo.csv"}
{exp
:channel:entries channel="pages" disable="categories|member_data|pagination" dynamic="no"}
{exp
:strip_html}
{title}
{url_title}{entry_id}{simple_content_body}
{
/exp:strip_html}
{
/exp:channel:entries}
{
/exp:download_content} 
Profile
 
 
Posted: 04 November 2011 08:26 AM   [ Ignore ]   [ # 18 ]  
Research Assistant
RankRankRank
Total Posts:  432
Joined  09-17-2010
Derek Jones - 04 November 2011 08:16 AM

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.

It looks like the issue is the commas in the string simple_content_body.  How can I get around that issue?

Profile
 
 
   
1 of 3
1