Page 1 of 1

new tag: File List on Frontend (e.g. list of pdf newsletters)

Posted: Fri Jun 06, 2008 5:40 pm
by ninja-lewis
I've been looking for a module/tag that would automatically create a list of PDF newsletters and display them on my site. The closest I found on the forge was a module called File List (not to be confused with the filelist tag released yesterday by Wiedmann) but there is yet to be anything uploaded to it. Hence I've tried to make my own despite my non-existant knowledge of PHP using the random image tag as a guide. I've learnt a lot from it and have now released a complete alpha version to forge for anyone who wants to try it.

To use the tag, you simply have to upload the files you want to display to a folder by FTP or using a file manager. The tag then creates an html table and populates it with a file extension icon, file name (as link to open the file in a new window), file size and file date for each entry. Using parameters in the tag you can choose which folder to watch, whether to show column headers, and the sort order.

At the moment, it is still quite basic and there are one or two errors that I haven't quite figured out, but it works okay on my test site at the moment. I used a similar plugin from another CMS as inspiration. This plugin had extra cells with   to space columns out better but I believe that isn't very accessible and should be done by CSS instead (unless someone knows better?)

Hopefully this'll help a few others who're looking for a way to display a list of PDF newsletters for example.

http://dev.cmsmadesimple.org/projects/file-list-table/

Re: new tag: File List on Frontend (e.g. list of pdf newsletters)

Posted: Fri Jun 06, 2008 5:46 pm
by calguy1000
Rather than hardcoding the output using tables, why not just spit the data out to smarty, then people can style things as they want.  it's much more flexible that way.

i.e:
{file_list ext='pdf' sortby='name' assign='myfilelist'}
{foreach from='myfilelist' item='onefile'}
...
{/foreach}

Re: new tag: File List on Frontend (e.g. list of pdf newsletters)

Posted: Fri Jun 06, 2008 8:43 pm
by ninja-lewis
Thanks for the feedback. Would that allow for multiple extensions though in one list? One of the uses I considered for the tag was a list of publications and resources for download by an organisation. Such a list could include various file formats such as PDFs, spreadsheets, and images.

Re: new tag: File List on Frontend (e.g. list of pdf newsletters)

Posted: Fri Jun 06, 2008 8:46 pm
by calguy1000
well, depending on your coding, it'd allow for anything.

My point is to not do the output yourself, but let smarty handle it.
then if people want to use tables, they can use tables... if they want to do it all in xhtml, they're still okay, as
it's up to them to define the output.

Re: new tag: File List on Frontend (e.g. list of pdf newsletters)

Posted: Sat Jun 07, 2008 2:28 am
by ninja-lewis
I see what you mean now - was a bit confused by the mention of ext=pdf in your example tag.

Is there anything in the forge where I can see a more complete example of using smarty in a similar manner? I'm new to coding my own php scripts and mainly used other tags and modules to pick up just the bits I needed. I get the gist of your example but it'd still be useful to see and understand the whole process before I attempt to do it myself.