Core Boxx – Dynamic Content Module

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.

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

LIBRARIES

  • lib/LIB-Contents.php The contents library.
  • lib/SQL-Contents.php Contents database table.

API

  • lib/API-contents.php Contents API endpoint.

ASSETS & PAGES

  • 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() in LIB-Contents.php – Generate a flat HTML file (or whatever file you may want to offer for download).
    • Change save() in LIB-Contents.php to run toFile() after saving.
  • 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_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

save($title, $text, $id)

Add or update content.

  • $title String, the content title/description.
  • $text String, the content body.
  • $id Int, provide the content ID to update. Leave as null to add a new one.
echo $_CORE->Contents->save(
  "TITLE", "CONTENT"
) ? "OK" : $_CORE->error ;
del($id)

Delete a piece of content.

  • $id Int, the content ID.
echo $_CORE->Contents->del(1) 
  ? "OK" : $_CORE->error ;
get($id)

Get a piece of content.

  • $id Int, the content ID.
$content = $_CORE->Contents->get(1);
getAll($search, $page)

Get all or search for content.

  • $search String, optional search term.
  • $page Int, optional current page.
$entries = $_CORE->Contents->getAll("search", 2);
toFile($id)

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

api/contents/save/

Add or update content.

  • $_POST["title"] String, content title or description.
  • $_POST["text"] String, content body.
  • $_POST["id"] Int, optional content ID.
api/contents/del/

Delete a piece of content.

  • $_POST["id"] The content ID.
api/contents/get/

Get a piece of content.

  • $_POST["id"] The content ID.
api/contents/getAll/

Search for a piece of content.

  • $_POST["search"] The search term.
  • $_POST["page"] The current page.

 

Leave a Comment

Your email address will not be published. Required fields are marked *