MV framework logo
  • Architecture
    • Philosophy
    • Technologies
  • Admin Panel
  • Changelog
  • Support
  • Feedback
Download Version 2.6 from 07.10.2022
Documentation
  • Architecture
    • Philosophy
    • Technologies
  • Admin Panel
  • Changelog
  • Support
  • Feedback
Getting started
  • Installation and launch
  • System folders
  • Launch of simple website
  • Pre-installed models
  • System settings
Models
  • General principles of models
  • Data types
  • Model settings
  • Simple models
  • Foreign keys
  • Trees
  • Many to many
  • Group
  • Records management
  • Simple model management
  • Additional options
Views and routes
  • General principles of views
  • Router object
  • MV object
  • Index, default and 404 templates
  • Creating a new template
  • Data display in template
  • Object of Record class
  • Files and images
  • Date and time
  • Redirects
  • Email delivery
  • Special methods
Forms
  • Forms creation
  • Form fields settings
  • Form validation rules
  • Form validation process
  • Operations with form data
  • Using data from models
  • Form methods
SQL queries
  • Query constructor
  • Direct queries
  • Pagination
  • Sorting
  • Filtration
  • Upload from CSV files
Sessions and security
  • Work with sessions
  • AJAX
  • Security
  • Debugging
Plugins
  • General principles of plugins
  • Additions to admin panel
  • Caching
Documentation
Getting started
  • Installation and launch
  • System folders
  • Launch of simple website
  • Pre-installed models
  • System settings
Models
  • General principles of models
  • Data types
  • Model settings
  • Simple models
  • Foreign keys
  • Trees
  • Many to many
  • Group
  • Records management
  • Simple model management
  • Additional options
Views and routes
  • General principles of views
  • Router object
  • MV object
  • Index, default and 404 templates
  • Creating a new template
  • Data display in template
  • Object of Record class
  • Files and images
  • Date and time
  • Redirects
  • Email delivery
  • Special methods
Forms
  • Forms creation
  • Form fields settings
  • Form validation rules
  • Form validation process
  • Operations with form data
  • Using data from models
  • Form methods
SQL queries
  • Query constructor
  • Direct queries
  • Pagination
  • Sorting
  • Filtration
  • Upload from CSV files
Sessions and security
  • Work with sessions
  • AJAX
  • Security
  • Debugging
Plugins
  • General principles of plugins
  • Additions to admin panel
  • Caching

Router object

This object is located inside the main "$mv" object and responsible for processing the passed URL.

  • getUrl() - returns cleared requested URL, if index page was requested, returns "/"
  • getUrlParts() - returns an array of URL parts
  • getUrlPart($index) - returns part of URL by given index (starts from 0)
  • getRoute() - returns the name of the file of included template
  • isIndex() - validates if the current page is the main page (index page)
  • isLocalHost() - check if the project located in local sever
  • defineCurrentPage($start_key) - described in Pagination section

There is "checkUrlPart($index [, $extra_check])" method in "$mv" object that contains Router object, as described in MV object section. This method checks if there is a part of URL under given index and returns it if so, otherwise shows 404 error. As an optional parameter "$extra_check" will be passed, if its value is "numeric", then this searched part of URL should be an integer.

Samples

///Trying to get 3rd part from URL like "/articles/32/83/"
$article_id = intval($mv -> router -> getUrlPart(2));
$mv -> display404($article_id); //If no such an element, then page is not found

//If main page is requested we include left column/sidebar
if($mv -> router -> isIndex())
    include $mv -> views_path."parts/left-column.php";

//Redirect with a parameter, that contains the back path
$mv -> redirect("create-order/?from=".$mv -> router -> getUrl());

//Checks if there is a numeric 2nd part in URL of "/user/652/"
//If not, show 404 error
$user_id = $mv -> checkUrlPart(1, "numeric");

Previous section

General principles of views

Next section

MV object

© 2012-2023, MV framework

MV tracker is based on open source MV framework
License