Skip to content

Getting Started

Lawrence Okoth-Odida edited this page Feb 22, 2017 · 8 revisions

Installation

  1. Download the files from the repository (/front_router and /front_router.php).
  2. Upload the above to the /plugins directory of your GetSimple installation.
  3. Log in to the Administration Panel.
  4. Go to the Plugins tab and enable the Front Router Plugin.

Management

  1. From the Administration Panel, go to the Plugins tab.
  2. From the Plugins section, click Manage routes from the sidebar.
  3. Click Add Route to add a new route.
  • All routes must have a routing URL (a valid regular expression where forward slashes shouldn't be escaped, e.g. page/(.*)) and an action (which dictates what to do when the route is successful). The action should return an array with a title (string) and a content (function), where content is parameterised by the matches on the route. See the API for more details.
  • Within the scope of your action code is an array called $args which has the matched results of the URL. For example, if routing to another/page/([a-z0-9-]+), and the URL is another/page/100-is-a-number, $args[0] == '100-is-a-number'. screenshot of admin panel
  1. Click x next to a route to delete it. You will be given a window prompt first in case you wish not to delete it.
  2. Reorder routes on the page by dragging their grey containers. They should be ordered by their specificity (e.g. if you have an error route for a page like page/(.*), that should come after any other routes on page.
  3. Changes will not be saved until you click Save Changes. Do so to save your work.

If your route is successfully matched to the user's URL, and the URL isn't of an existing page, the action will be executed. The page title and content will change in accordance with the title and content values provided by your action.

Pretty URLs (v0.3+)

If you have pretty URLs enabled on your site, your routes will go through:

SITEURL/your/route/here

If they are not enabled, they will go through:

SITEURL/index.php?id=your/route/here

Ensure that if you are putting any URLs on your site, you have the necessary prefix (i.e. if pretty URLs are disabled, ensure that you have index.php?id= before the URL).