Repository navigation
Templates
The UCF Document Plugin provides a single default template for a single document. This layout handles the forced download, inline download or redirect to the appropriate document depending on the situation. This template can be overridden by createing a single-document.php template within your theme.
The included template uses the following steps to direct the user to the document:
- If the document is an uploaded file it will: a. Open the document in the browser if the browser supports loading the file type "inline." b. Force the download of the document if the "Force Download" setting is check in the Settings.
- If the document is an external page or file, it will redirect the user to the page or file.
The included template does not return a webpage, so the user will not leave the page they were on when they clicked on the document.
To create a new template for documents, create a single-document.php file within your theme. Within this template, you can follow similar logic to what is used in the default template, or you can provide your own. Note that if you are not providing a visual template, be sure to not call wp_head or wp_footer and be sure to return or exit at the end of any logical branch.
It is also recommended to handle 404 logic within your template if the file does not exist. Because uploaded documents are pointing to media objects within WordPress, it's possible for the actual file a document points to to be deleted without the document post being aware.