Jump to:

23486 Posts in 18995 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » PDF Download link

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

Page: 1 2
Go to End
Author Topic: 4745 Views
  • Invader_Zim
    Avatar
    Community Member
    141 Posts

    Re: PDF Download link Link to this post

    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

  • hi-tech
    Avatar
    Community Member
    9 Posts

    Re: PDF Download link Link to this post

    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!

  • Invader_Zim
    Avatar
    Community Member
    141 Posts

    Re: PDF Download link Link to this post

    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

  • hi-tech
    Avatar
    Community Member
    9 Posts

    Re: PDF Download link Link to this post

    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;
       }

  • hi-tech
    Avatar
    Community Member
    9 Posts

    Re: PDF Download link Link to this post

    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.

  • Invader_Zim
    Avatar
    Community Member
    141 Posts

    Re: PDF Download link Link to this post

    Hehe,
    M A G I C

    ... or a flushed cache or something.

    4745 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.