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
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
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
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
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
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
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
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
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
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
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
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
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
A particular slide catching your eye?
Clipping is a handy way to collect important slides you want to go back to later.