INTRODUCTION
This is a simple dynamic content module for Core Boxx. Articles, posts, code snippets, descriptions – Save whatever content you need into the database and retrieve it dynamically.
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.
Download Core Boxx Contents Module | GitHub | Source Forge
INSTALLATION
- Install the “main” Core Boxx first, then unzip this module into your existing Core Boxx project folder.
- Import
lib/SQL-Contents.sql
into your database.
FILES LIST
lib/LIB-Contents.php
The contents library.lib/API-contents.php
Contents API endpoint.pages/PAGE-content.php
Demo 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.php
to runtoFile()
after saving.
- Complete
- Protect the API endpoint! All of these are admin functions.
CONTENT REFERENCE
CONTENT TABLE
Function | Description & Quick Example |
content_id |
Primary key, the content ID. |
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. |
CONTENT LIBRARY FUNCTIONS
Add or update content.
$title
String, the content title/description.$text
String, the content body.$id
Int, provide the content ID to update. Leave asnull
to add a new one.
echo $_CORE->Contents->save(
"TITLE", "CONTENT"
) ? "OK" : $_CORE->error ;
Delete a piece of content.
$id
Int, the content ID.
echo $_CORE->Contents->del(1)
? "OK" : $_CORE->error ;
Get a piece of content.
$id
Int, the content ID.
$content = $_CORE->Contents->get(1);
Get all or search for content.
$search
String, optional search term.$page
Int, 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.
$id
Int, content ID.
CONTENTS API
Accessible at http://yoursite.com/api/contents/REQUEST/
. These are pretty much a replica of the above library functions, except in REST API format. Feel free to delete api/API-contents.php
if you don’t intend to integrate an API.
Add or update content.
$_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.
Search for a piece of content.
$_POST["search"]
The search term.$_POST["page"]
The current page.