The module adds a new
DMSDocument model which allows management
of large amounts of files, and their relations to pages.
In contrast to the
File model built into SilverStripe core,
it aims to wrap storage and access concerns in a generic API,
which allows more fine-grained control over how the documents are
managed and exposed through the website.
Additionally, documents are stored and managed as part of a page instead of away in a separate assets store.
Read more about the DMS module in this blog post on silverstripe.org
While the DMS architecture allows for remote storage of files,
the default implementation (the
DMS class) stores them locally.
Relations to pages and tags are persisted as many-many relationships
through the SilverStripe ORM.
File locations in this implementation are structured into
subfolders, in order to avoid exceeding filesystem limits.
The file name is a composite based on its database ID
and the original file name. The exact location shouldn't
be relied on by custom logic, but rather retrieved through
the API (
dms-assets/ 0/ 1234~myfile.pdf 1/ 2345~myotherfile.pdf
The file location is set via the
DMS::$dmsFolder static, and points to a location in the webroot.
Add a simple include to any of your .ss templates to display the DMSDocuments associated with the current page on the front-end.
<% include Documents %>
Create by relative path:
$dms = DMS::getDMSInstance(); $doc = $dms->storeDocument('assets/myfile.pdf');
Create from an existing
$dms = DMS::getDMSInstance(); $file = File::get()->byID(99); $doc = $dms->storeDocument($file);
Note: Both operations copy the existing file.
$dms = DMS::getDMSInstance(); $docs = $dms->getByTag('priority', 'important')->First(); $link = $doc->getLink(); // Set default download behavior ('open' or 'download'). 'download' is the system default // Attempt to open the file in the browser Config::inst()->update('DMSDocument', 'default_download_behaviour', 'open');
Or in you config.yml:
DMSDocument: default_download_behaviour: open
// Find documents by page $dms = DMS::getDMSInstance(); $page = SiteTree::get()->filter('URLSegment', 'home')->First(); $docs = $dms->getByPage($page); // Add documents to page
// Find documents by tag $dms = DMS::getDMSInstance(); $docs = $dms->getByTag('priority', 'important'); // Add tag to existing document $doc = Document::get()->byID(99); $doc->addTag('priority', 'low'); // Supports multiple values for tags $doc->addTag('category', 'keyboard'); $doc->addTag('category', 'input device'); // Removing tags is abstracted as well $doc->removeTag('category', 'keyboard'); $doc->removeTag('category', 'input device'); $doc->removeAllTags();
Translations of the natural language strings are managed through a third party translation interface, transifex.com. Newly added strings will be periodically uploaded there for translation, and any new translations will be merged back to the project source code.
Please use https://www.transifex.com/projects/p/silverstripe-dms/ to contribute translations, rather than sending pull requests with YAML files.
See the "i18n" topic on doc.silverstripe.org for more details.
Module rating system helping users find modules that are well supported. For more on how the rating system works visit Module standards
Score not correct? Let us know there is a problem