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

[solved] force file download


10 Posts   2756 Views


30 September 2011 at 3:07am Community Member, 528 Posts

Okay I think I'm starting to understand what you're trying to do. The way you have it structured you're passing download as a variable to the link method. What you want to do is create a urls that calls the page/action/id method. So it should be

<a href="{$Top.Link}/download/{$SongFile.ID}" title="$Title.XML">Download</a>

so the url is structured: url of page / method you want to call / id you want to pass

Hope that helps


30 September 2011 at 3:18am (Last edited: 30 September 2011 3:22am), Community Member, 16 Posts

Sorry for the confusion, but the code i posted is actualy working.

$Link is a method in the SiteTree model and it takes an $action optional parameter, hence the $Top.Link(download).

Here's a link to the API documentation [url][/url]