TABLE OF CONTENTS
DOWNLOAD & INSTALLATION
First, the download links for the module, and also “installation instructions”.
LICENSE & DOWNLOAD
Core Boxx is released under the MIT License. You are free to use it for personal and commercial projects, and modify it as you see fit. On the condition that the software is provided “as-is”. There are no warranties provided and “no strings attached”. Code Boxx and the authors are not liable for any claims, damages, or liabilities.
INSTALLATION
- Copy/unzip this module into your existing Core Boxx project folder.
- Access
http://your-site.com/install/content, this will automatically:- Import
lib/SQL-Contents.sqlinto your database. - Add a new
$wild = [ "post/" => "POST-load.php" ]route toHOOK-Routes.php. - Delete
PAGE-install-content.phpitself.
- Import
- Open
http://your-site.com/post/hellofor the demo. - Feel free to use
$_CORE->Contents->save(SLUG, TITLE, TEXT)to create more posts. - Or if you have installed the admin module –
http://your-site.com/admin/content
SORRY FOR THE ADS...
But someone has to pay the bills, and sponsors are paying for it. I insist on not turning Code Boxx into a "paid scripts" business, and I don't "block people with Adblock". Every little bit of support helps.
Buy Me A Coffee Code Boxx eBooks
FILES LIST
LIBRARIES
lib/LIB-Contents.phpThe contents library.lib/SQL-Contents.phpContents database table.
API
lib/API-contents.phpContents API endpoint.
ASSETS & PAGES
assets/tinymceTinyMCE WYSIWYG editor.assets/ADM-content.jsContents admin page JS.pages/ADM-content.phpContents admin page.pages/ADM-content-form.phpAdd/edit content page. Loaded via AJAX.pages/ADM-content-list.phpContents list. Loaded via AJAX.pages/POST-load.phpAllhttp://your-site.com/post/SLUGwill route here. Loads content from the database and generates the page.
DEVELOPMENT NOTES
- This module will work “as it is”. Just save your content in the database and use
get()to retrieve them. - But an alternative for possibly better performance is to:
- Complete
toFile()inLIB-Contents.php– Generate a flat HTML file (or whatever file you may want to offer for download). - Change
save()inLIB-Contents.phpto runtoFile()after saving.
- Complete
- Protect the API endpoint! All of these are admin functions.
DATABASE REFERENCE
There is only one table to store the content. Feel free to expand on it – Maybe add categories and tags.
CONTENT TABLE
| Function | Description & Quick Example |
content_id |
Primary key, the content ID. |
content_slug |
Content URL slug, unique. |
content_title |
Title or short description of the content. |
content_text |
Text or body of the content. |
date_created |
Date when the content is created. |
date_modified |
Last modified timestamp. |
LIBRARY REFERENCE
Lastly, the list of library functions and API endpoints.
CONTENT LIBRARY FUNCTIONS
Add or update content.
$slugString, the URL slug.$titleString, the content title/description.$textString, the content body.$idInt, provide the content ID to update. Leave asnullto add a new one.
echo $_CORE->Contents->save(
"SLUG", "TITLE", "CONTENT"
) ? "OK" : $_CORE->error ;
Delete a piece of content.
$idInt, the content ID.
echo $_CORE->Contents->del(1)
? "OK" : $_CORE->error ;
Get a piece of content.
$idInt/string, the content ID or URL slug.
$content = $_CORE->Contents->get(1);
Get all or search for content.
$searchString, optional search term.$pageInt, optional current page.
$entries = $_CORE->Contents->getAll("search", 2);
An incomplete support function for save(), generate a static file. Complete it if you want, good for HTML, CSS, Javascript, or maybe files that you want to offer for download.
$idInt/String, content ID or URL slug.
CONTENTS API
Add or update content.
$_POST["slug"]String, URL slug.$_POST["title"]String, content title or description.$_POST["text"]String, content body.$_POST["id"]Int, optional content ID.
Delete a piece of content.
$_POST["id"]The content ID.
Get a piece of content.
$_POST["id"]The content ID or URL slug.
Search for a piece of content.
$_POST["search"]The search term.$_POST["page"]The current page.
