A Static content plugin for CakePHP using Markdown-formatted text files. Very similar to the content implementation of the Statamic CMS.
Copy plugin folder into the app/Plugin directory
You may need to run this command in the Cake console to create the table for cached Statalike content
cake schema create --plugin Statalike
Set up Statalike's content folder location in app/Config/bootstrap.php:
/* Statalike Configuration */
Configure::write('Statalike.content_folder', APP.'/View/Content/_content/');
Set up your routes for content. There are a few different ways to configure Statalike:
To use for all content that isn't a controller set it as the last entry, before the CakePHP default routes. Statalike will return a NotFoundException if the content doesn't exist in your content folder.
/* Content Routing using Statalike Plugin */
Router::connect('/**', array('plugin' => 'Statalike', 'controller' => 'content', 'action' => 'display'));
You can also route to to only specific pages
Router::connect('/', array('plugin' => 'Statalike', 'controller' => 'content', 'action' => 'display', 'page'));
The final 'page' variable above is the slug of the content you want to display.
Create custom views for your content by creating the folders below inside your Cake project:
- app/View/Plugin/
- Statalike
- Content
- view.ctp
- view2.ctp
- Layouts
- layout.ctp
- layout2.ctp
- Content
- Statalike
You can then set custom variables in your page's YAML frontmatter to choose the layout or view using:
_cake_layout: layout
_cake_view: view
To use your site's layouts, create a layout file containing a PHP require() method call for the layout you want to use. This is created in the app/View/Plugin/Statalike/Layouts/ folder:
<?php
// Use the default layout
require(ROOT.DS.APP_DIR.'/View/Layouts/default.ctp');
?>