Routing - lokothodida/DM_Matrix GitHub Wiki

Routing and the routing table allows you to use TheMatrix tables like GetSimple Pages.

Each record in the table consists of a route and a rewrite rule. The route is used when a page is not found the error404 hook is fired. The routes table is checked to see if a corresponding route is found, if so the rewrite rule is used to fetch the page specified.

So for example if you wanted to setup a simple blogging system, create a template file called blogger.php Next setup a route in the routing table

route = blog
rewrite = blogger.php 

Next setup a table called "blog" with the following fields:

slug - slug
pubdate - datetimepicker
author - text
tags - text
content - wysiwyg

Build your Blog header list ensuring the link is to http://yoursite.com/blog/slug

When a page is requested for http://yoursite.com/blog/whatever-your-slug-name-is

The system will throw an error404 as it can't find the GS page "blog"

The routing tables will check the routing table and see you have a route and will pass the page "blogger.php" to the system and will load that page.

As the URI is passed to that page you can parse the variable $uri to get your slug name.

The following code will fetch the corresponding blog entry on the "blogger.php" page.

<?php 
$parts=explode('/',$uri);
$str=(string)$parts[1];
$myquery = "select * from blog where slug = '".$str."'"; 
$result=DM_query($myquery);
echo $result[0]['content'];
?>