Core Boxx – Pretty URL Module

This is a simple pretty URL module for Core Boxx. That is, turning an ugly URL like http://site.com/about-us-12345.php to http://site.com/about-us/.

 

TABLE OF CONTENTS

Download & Notes Quick Reference

 

 

DOWNLOAD & NOTES

First, here are the download links and a quick “setup guide” for the impatient folks who don’t have the patience to read through everything.

 

DOWNLOAD LINKS

Download Core Boxx Pretty URL Module | GitHub | Source Forge

 

LICENSE

Core Boxx is released under the MIT License. You are free to use it for your own personal and commercial projects, modify it as you see fit. On the condition that there 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 & REQUIREMENTS

  • Download and set up the “main Core Boxx” if you have not already done so.
  • Apache URL rewrite module must be enabled.
  • Take note, this module will override the index.php file and introduce a new pages folder.

 

QUICK REFERENCE

This section is a quick walkthrough of the general module structures.

 

REAL QUICK WALKTHROUGH

  • There are no library files in this module, only index.php.
  • How it works is simple – Generate a .htaccess file that redirects all URLs to index.php. Less the existing files and folders.
  • So in index.php, we can do our own custom URL handling. The default mechanism is kept as simple as possible, it will look for corresponding files in the pages folder.
  • For example, http://site.com/hello/world/ will “translate” into pages/PAGE-hello-world.php.
  • Feel free to modify as you see fit – Load contents from the database, create your own HTML template, use your own favorite client-side frameworks.

 

I WANT TO LOAD CONTENT FROM THE DATABASE

Yes, it is possible to turn this into a “content management system” like WordPress or Drupal.

  • Create your own content module, or modify it from the content module.
  • Introduce a new contents database table.
    • content_slug Text, primary key.
    • content_title Title of page.
    • content_text The main page content.
  • Change index.php to load from the database instead.
    • $slug = trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
    • $content = $_CORE->Content->get($slug);
    • Show page if contents are found, 404 if not.

Leave a Comment

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