Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Uploading downloadable documents


Reply


2 Posts   313 Views

Avatar
bananaswim

Community Member, 2 Posts

14 December 2012 at 2:27am

Hi,

Am totally new to Silverstripe so am only competent with absolute basics at the moment. Currently I am just working on getting the content up and a vague order to things - I will work on the aesthetics later when I understand a bit more.

I need to have a section where I can have documents such as forms and information packs that people can download. So word and pdf documents which you can click on and either open or download. How possible is this and if it's easy, how do I go about it?

Please use simple language if explaining else I won't have a clue!

Cheers,

Avatar
zenmonkey

Community Member, 528 Posts

14 December 2012 at 3:51am

Super simple, if you don't need front end upload. You'd just need to create a cusotm page type http://doc.silverstripe.org/framework/en/tutorials/1-building-a-basic-site and give it a $has_many relation with the File Object http://doc.silverstripe.org/framework/en/tutorials/5-dataobject-relationship-management

Then in that custom page template call some thing like
<% loop Files %>
<a href="$Filename">$Name</a>
<% end_loop %>

This assume you create the relation as
static $has_many = array("Files" => "File",);

In the template you could also use $Title instead of $Name if you don't want to see the extension.

Welcome to SilverStripe. I started using it a few years ago with 0 PHP knowledge, great way to learn since it handles all the messy parts of the Database part and wraps it in a really easy to use/learn method