21309 Posts in 5738 Topics by 2603 members
General Questions
SilverStripe Forums » General Questions » Unable to display attached files in template [SOLVED]
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 833 Views |
-
Unable to display attached files in template [SOLVED]

25 February 2011 at 10:36am
Hello!
I have problem to display attached files. Files to attach and display a list of DOM (Uploadify). Generated link does not work. Does my template is all ok?
OfertaHolder.ss
-----------------------
<% if Plik %>
<% control Plik %>
pobierz plik: <a href="$MyFile.URL">$MyFile.Title ($MyFile.Size) [$MyFile.Extension]</a><% end_control %>
<% end_if %>
------This is my code:
MyFile.php:
--------------<?php
class MyFile extends File {
static $has_one = array (
'OfertaPage' => 'OfertaPage'
);
}
------OfertaPage.php:
--------------
<?php
class OfertaPage extends Page {
static $db = array(
'Pokazemail' => 'Boolean',
'Pokaztel' => 'Boolean','Imienazwisko' => 'Text',
'Tel' => 'Text',
'Email' => 'Text'
);
static $has_one = array(
'Zdjecie' => 'Image'
);static $has_many = array (
'Plik' => 'MyFile'
);function getCMSFields() {
$fields = parent::getCMSFields();$fields->addFieldToTab("Root.Content.Images", new ImageField('Zdjecie'));
$fields->addFieldToTab("Root.Content.File", $MFile = new MultipleFileUploadField('Plik'));$fields->addFieldToTab('Root.Content.Main', new TextField('Imienazwisko', 'Imię i nazwisko'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new CheckboxField ('Pokaztel', 'Pokaż tel lub www'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new TextField('Tel'), 'Content');$fields->addFieldToTab('Root.Content.Main', new CheckboxField ('Pokazemail', 'Pokaż email'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new TextField('Email'), 'Content');$MFile ->allowFolderSelection();
return $fields;
}
}
class OfertaPage_Controller extends Page_Controller {
} -
Re: Unable to display attached files in template [SOLVED]

25 February 2011 at 10:44am
Try $MyFile.Filename
-
Re: Unable to display attached files in template [SOLVED]

25 February 2011 at 10:55am
Does't work
Title, link don't display - is empty... -
Re: Unable to display attached files in template [SOLVED]

25 February 2011 at 10:29pm
Maybe there is another way to load multiple files and displays them in a template?
-
Re: Unable to display attached files in template [SOLVED]

26 February 2011 at 12:42am Last edited: 26 February 2011 12:43am
Big Thanks to Matt Clegg!! Now work fine.
I had a bug in the template, correct code:
<% if Plik %>
<% control Plik %>
pobierz plik: <a href="$URL">$Title ($Size) [$Extension]</a><% end_control %>
<% end_if %>
| 833 Views | ||
|
Page:
1
|
Go to Top |


