Hi UncleCheese. I have got the Add Resource button display in the CMs and can upload files to the server but how do I display the file documents uploaded on the on the web site?
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
DataObjectManager Module /
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba
FileDataObjectManager - question?
- Previous 10 entries
- 1
- 2
- Page 33(current)
- 4
- Next 10 entries
Hello FireMe!
Thanks to your request for help, I have got the Add Resource button working on the CMS but can you please tell me what you need to add to the page template to display the upload resource files.
I have also added $Resources on the page.ss below $Content
The resource files uploaded names get displayed on the front end but links directly to the root of the site.
How can you make it display the correct link to file on the server, the file date and the size of the file?
Thanks for your help.
hi ulysses
this is my resource page template
<h1>Forms</h1>
<% control FilterForms %>
<div id="downloads">
<h3>$Name</h3>
<p>$Description</p>
<p><b>Category:</b> $Category <b>File type:</b> $Attachment.FileType <b>File Size:</b> $Attachment.Size <b>Download:</b> <a href="$Attachment.URL">$Name</a>
</div>
<% end_control %>
<h1>Videos</h1>
<% control FilterVideos %>
<div id="downloads">
<h3>$Name</h3>
<p>$Description</p>
<p><b>Category:</b> $Category <b>File type:</b> $Attachment.FileType <b>File Size:</b> $Attachment.Size <b>Download:</b> <a href="$Attachment.URL">$Name</a>
</div>
<% end_control %>
so the main ones for calling are
$Attachment
so you would just add .FileType or .size .URL for link $Attachment.FileType $Attachment.Size <a href="$Attachment.URL">$Name</a>
plus there is
$Category $Description $Name
for calling the category description and name of the file
hope this helps
FireMe
Hi FireMe,
Thanks for that info. Can you please advise where I insert this code. Fairly new to this.
I have the files Resource.php & ResourcePage.php in the /mysite/code/ folder.
I can email you my files. My email is mauricio@ulysses.co.nz
you need to add something like this too your ResourcePage.php controller
class ResourcePage_Controller extends Page_Controller
{
function MyFileObjects()
{
$filter = Director::urlParam('Action');
return $filter ? $this->Resources("Category = '$filter'") : $this->Resources();
}
}
then you need to create a ResourcePage.ss and put in your themes folder under templates > layout
some thing like this
<% control MyFileObjects %>
<div id="downloads">
<h3>$Name</h3>
<p>$Description</p>
<p><b>Category:</b> $Category <b>File type:</b> $Attachment.FileType <b>File Size:</b> $Attachment.Size <b>Download:</b> <a href="$Attachment.URL">$Name</a>
</div>
<% end_control %>
Thanks for your help. got that going now.
Any ideas how to add the file upload date as well?
i think you would just have to a date field to your array on your Resource.php
<?php
class Resource extends DataObject
{
static $db = array (
'Name' => 'Text',
'Date' => 'Date',
'Description' => 'Text',
'Category' => "Enum('Forms, Videos')"
);
static $has_one = array (
'Attachment' => 'File',
'ResourcePage' => 'ResourcePage'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Name'),
new CalendarDateField('Date'),
new TextareaField('Description'),
new DropdownField('Category','Category', singleton('Resource')->dbObject('Category')->enumValues()),
new FileIFrameField('Attachment')
);
}
}
?>
but im not to sure about this, best to ask uncle cheese!
FireMe!
Hi FireMe,
You were absolutely spot on. Awesome. Thanks heaps. That's what I needed.
Check out the page under development: http://biztravel.ulysses.co.nz/test/
- Previous 10 entries
- 1
- 2
- Page 33(current)
- 4
- Next 10 entries