A prime example of how DropCMS could be used would be the display of a simple PDF restaurant menu. This is content that might change weekly. A client could be setup with a simple FTP account that allows them to easy create and upload revisions to a specific directory on the website. DropCMS could be used to read and embed a named PDF file from that location. If the PDF file goes missing, then rather than the page 'exploding' into dozens of error messages, you can simply display alternative stacks or nothing at all in its place. DropCMS could be a good precursor before you need to consider a more feature-rich CMS like WebYep.

System requirements

You need a web server that supports PHP 7.1 or later. If in doubt, use the UsefulStack in diagnostic mode to check, or speak with your web hosting provider.

Setup

Follow the instructions to use DropCMS.
  1. Once installed into Stacks and RapidWeaver, open your Stacks library and search for DropCMS.
  2. Drag and drop a copy of DropCMS into your webpage.
  3. Provide the relative path to the text, PDF or image file you want to embed. This MUST be a file stored on your own web server and you need to be using a relative path (a full URL starting 'https://' is unlikely to work).
  4. Within the stack settings, customise what should happen when the file is found and an action for when the file is not found.
  5. Attach the file as a resource in RapidWeaver of upload it to your web server.
  6. Publish the webpage when done, to check DropCMS is working as expected.

DropCMS will automatically change your page extension from .html to .php in the Page Inspector. If the page has previously been published using a .html extension, you will need to manually delete that old page, otherwise it will continue to load.

Two PHP embed methods are provided for HTML and text files; these being file_get_contents and cURL. Depending on how the web server is configured, you may find only one of these methods works. The idea is to pull HTML or plain text into the webpage, and merge it directly into the rest of your page content. Simple HTML tags may be used.

Relative paths

Search online if you are unsure what a relative path is or how it differs from an absolute path (the latter is not supported by DropCMS). To summarise, relative paths work on the CD or 'current directory' principle. That is to mean that you start at the current location and count how many directories down from root (the homepage) you are. For each level, you express this as ../ notations. Once back at root level, you then provide the path down to the location of the file you want to use. A typical relative path you enter into DropCMS might typically look like:

../../shared-files/pricelist.pdf

As always, you should adopt a strict protocol of only using web safe folder and file names. That is to mean the folder or file name contains no spaces or special characters; only letters, numbers, hyphens and underscores.
 

Contribute

If you find this stack element useful in your personal or commercial web projects; please consider making a small contribution towards ongoing support and updates. There are many different ways you can contribute to the Stacks4Stacks project, and benefits for doing so.