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.

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.

General Questions /

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

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

PDF Download link


Go to End


14 Posts   8586 Views

Avatar
Invader_Zim

Community Member, 141 Posts

18 January 2011 at 11:05pm

Edited: 18/01/2011 11:06pm

Uh... that's strange.
I did this in a quick test installation:
Page.php

static $has_one = array(
    'PDF'  => 'File'
);

function getCMSFields() {
    $fields = parent::getCMSFields();
    $fields->addFieldToTab("Root.Content.Files", new FileIFrameField('PDF'));

     return $fields;
}

Template:
<div id="PcFile">
    <a href="$PDF.Link">$PDF.Title</a>
</div>

Everything worked as expected, i was able to upload a .pdf and there was the correct download link showing up on the frontpage (with neat little pdf icon)

So, i am a little bit lost with your problem, sorry.
Maybe some .htaccess issues?

Cheers,
Christian

Avatar
hi-tech

Community Member, 9 Posts

19 January 2011 at 12:35am

Hi Invader,

thanks for your efforts!

I left the .htaccess files untouched. So the .htaccess in my assets folder contains:

Deny from all
<FilesMatch "\.(html|htm|xhtml|js|css|bmp|png|gif|jpg|jpeg|ico|pcx|tif|tiff|au|mid|midi|mpa|mp3|ogg|m4a|ra|wma|wav|cda|avi|mpg|mpeg|asf|wmv|m4v|mov|mkv|mp4|swf|flv|ram|rm|doc|docx|txt|rtf|xls|xlsx|pages|ppt|pptx|pps|csv|cab|arj|tar|zip|zipx|sit|sitx|gz|tgz|bz2|ace|arc|pkg|dmg|hqx|jar|xml|pdf)$">
Allow from all
</FilesMatch>

This is my top level .htaccess:

### SILVERSTRIPE START ###
<Files *.ss>
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Files>

<Files web.config>
Order deny,allow
Deny from all
</Files>

ErrorDocument 404 /assets/error-404.html
ErrorDocument 500 /assets/error-500.html

<IfModule mod_alias.c>
RedirectMatch 403 /silverstripe-cache(/|$)
</IfModule>

<IfModule mod_rewrite.c>
SetEnv HTTP_MOD_REWRITE On
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
</IfModule>
### SILVERSTRIPE END ###

I've made good progress in my ss efforts today ... If I get this pdf thing fixed somehow, I will be very happy!

Avatar
Invader_Zim

Community Member, 141 Posts

19 January 2011 at 1:02am

Ah, ja...
This is my patched (more info here:http://silverstripe.org/general-questions/show/15505 ) .htaccess file from /assets directory:

Deny from all
<FilesMatch "\.(html|htm|xhtml|js|css|bmp|png|gif|jpg|jpeg|ico|pcx|tif|tiff|au|mid|midi|mpa|mp3|ogg|m4a|ra|wma|wav|cda|avi|mpg|mpeg|asf|wmv|m4v|mov|mkv|mp4|swf|flv|ram|rm|doc|docx|txt|rtf|xls|xlsx|pages|ppt|pptx|pps|csv|cab|arj|tar|zip|zipx|sit|sitx|gz|tgz|bz2|ace|arc|pkg|dmg|hqx|jar|xml|pdf)$">
	Allow from all
</FilesMatch>

# We disable PHP via several methods
# Replace the handler with the default plaintext handler
AddHandler default-handler php phtml php3 php4 php5 inc

<IfModule mod_php5.c>
	# Turn the PHP engine off
	php_flag engine off
</IfModule>

It's pasted here again.
Replace yours and give it another try :-)

Avatar
hi-tech

Community Member, 9 Posts

19 January 2011 at 2:56am

Hallo Christian,

und danke... :) But that wasn't it. Same error.
The path in the database is fine, there seems to be a problem with instantiation a file object.

This snippet from File.php just delivers "/assets".

function Link($action = null) {
return Director::baseURL() . $this->RelativeLink($action);
}

function RelativeLink($action = null){
return $this->Filename;
}

Avatar
hi-tech

Community Member, 9 Posts

19 January 2011 at 4:48am

Hey,

something really weird happend. I was just working on my templates when I suddenly recognized a file icon on my detail page. I wanted to find out what the matter was before, checked on special characters etc., but ss has no problems with special characters.

So I have my longed for link, but I can't say what the problem was.

Avatar
Invader_Zim

Community Member, 141 Posts

19 January 2011 at 4:56am

Hehe,
M A G I C

... or a flushed cache or something.

Go to Top