-
Notifications
You must be signed in to change notification settings - Fork 3
Getting Started
Lawrence Okoth-Odida edited this page Feb 22, 2017
·
8 revisions
- Download the files from the repository (
/front_router
and/front_router.php
). - Upload the above to the
/plugins
directory of your GetSimple installation. - Log in to the Administration Panel.
- Go to the Plugins tab and enable the Front Router Plugin.
- From the Administration Panel, go to the Plugins tab.
- From the Plugins section, click Manage routes from the sidebar.
- 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 anarray
with atitle (string)
and acontent (function)
, wherecontent
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 toanother/page/([a-z0-9-]+)
, and the URL isanother/page/100-is-a-number
,$args[0] == '100-is-a-number'
.
- 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.
- 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 onpage
. - 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.
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).