URL Routing Options and Customization PHP


Published on

Customize and control actions of a route based on rules and the options associated with those rules.

Published in: Technology, Design
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

URL Routing Options and Customization PHP

  1. 1. URL Routing Options & Customization www.prodigyview.com
  2. 2. OverviewObjectiveCustomize and control actions of a route based on rules and the optionsassociated with those rules.Requirements Understanding of an url Installed version of ProdigyView with a database An understanding of MVC Design Understanding the route rules, read Routing Basics tutorial. Understanding of user roles and user access levelsEstimated Time10 minutes www.prodigyview.com
  3. 3. Follow Along With Code Example1. Download a copy of the example code at www.prodigyview.com/source.2. Install the system in an environment you feel comfortable testing in.3. Proceed to mvc/helium/config/bootstrap/router.php www.prodigyview.com
  4. 4. Router OptionsThe router has a list of options in it that can change how yoursite functions depending on the rule and options associatedwith the rule. These options include: Access Level User Roles Redirect SSL Changing Controllers and Actions www.prodigyview.com
  5. 5. RedirectsIf a url matches a specified criteria, a redirect can direct theuser to another page on the site or an external site.Redirects are great for closing off sections of your site orshortening urls. 1. If the url is ‘www.example.com/users/login’ 2. Redirect to ‘www.example.com/login’ www.prodigyview.com
  6. 6. Changing Route Actions Building upon the last example, the redirect sends us to www.example.com/login page, which has no controller or action. Below we are going to set a rule, if the url is /login, then to specify which controller and action to call.1. If url path is ‘/users/login’, redirect to url ‘/login’ 2. If the url is ‘/login’, use the controller users and the action login
  7. 7. Specify RoutesSimilar to changing routes, we can specify completelynew routes based on the rules of an url1. If the url path is ‘/rss’ 2. Route to the controller post and set the action to rss www.prodigyview.com
  8. 8. Customize UrlsThe previous slides show how to shorten urls and alsocustomize how your application will act based on the urls.Based on the past example, can you tell what is happeningbelow? www.prodigyview.com
  9. 9. Access LevelUsing the User Manager that comes with ProdigyView,every user has an access level. Using that access level, wecan restrict a user’s access to certain with urls.1. Set the rule to be the url path 2. Require that the user have an‘/post/add’ access level of 1 to access this area 3. If the user does not have the required access level, redirect them to this url
  10. 10. User Roles Similar to access levels, users can be restricted to certain areas based on their roles, another way of easily implementing access control on your site.1. Set the rule to be the url path 2. Require that the user have the‘/user/admin’ role ‘Admin’ 3. If the user does not have the required role, redirect them to this url www.prodigyview.com
  11. 11. Automatic SSLIf you are developing a site that requires ssl, you might want toset a rule that being on the page to purchase a productrequires a ssl certificate is to be using. This is very easy toimplement using the route options. 1. Set the rule to be the url path /purchase 2. If path matches rule, force an ssl connection
  12. 12. Deactivate SSLIn other instances, you might be to ensure that an sslconnection is not used, no matter what the circumstancesare. 1. Set the rule to be the url path ‘/logout’ 2. If path matches the rule, remove an ssl connection if one is present www.prodigyview.com
  13. 13. Review1. Redirects can be added to a rule by defining a redirect in the options.2. In an MVC setting, rules can be routes to use a specific controller and action that is not normally associated with that route.3. Rules can be used to block access to a location on the site with access levels and roles.4. SSL can be automatically activated or deactivated depending on a rule. www.prodigyview.com
  14. 14. API ReferenceFor a better understanding of the PVRouter, check out theapi at the two links below.PVRouter More TutorialsFor more tutorials, please visit:http://www.prodigyview.com/tutorials www.prodigyview.com