MV object
MV object is being used to access models object and other functions on the frontend of the website.
Own properties (public):
- $root_path - path (URL) the root of the website (on working domain usually "/"), defined in "config/setup.php" file
- $media_path - path (URL) from root to folder "/media/"
- $views_path - path (folder) from root of file system to folder with templates "/views/"
- $include_path - path (folder) from root of file system to project, will be used for "include" and "require" functions
- $domain - domain name from config file
These properties are closely connected with System settings section.
Own methods of $mv object:
- redirect(), reload(), display404() - redirects to other pages inside the website, more details in Redirects section
- checkUrlPart($index) - check URL for availability of requested part, more details in Object of Router class
Objects inside $mv object:
- $registry - an access to the settings from config files, read more in System settings
- $router - router, Object of Router class
- $db - database manager, performing Direct queries to database
All active models are accessible in $mv object by their names (see samples).
Samples
//URLs to links <a id="logo" href="<? echo $mv -> root_path; ?>"> <img src="<? echo $mv -> media_path; ?>images/logo.png" alt="Our company" /> </a> <link rel="stylesheet" type="text/css" href="<? echo $mv -> media_path; ?>css/style.css" /> <script type="text/javascript" src="<? echo $mv -> media_path; ?>js/jquery.js"></script> //Include of template part include $mv -> views_path."main-header.php"; include $mv -> views_path."parts/left-column.php"; //Using built-in objects $mv -> registry -> getSetting("AdminPanelPath"); $mv -> db -> getCell("SELECT `email` FROM `users` WHERE `id`='236'"); //Models access echo $mv -> pages -> displayMenu(74); $user = $mv -> users -> findRecord(array("email" => "aaa@bbb.cc", "active" => 1)); //Data from simple model echo $mv -> options -> topic; //An alternative way to access data of simple model $object = $mv -> options -> loadIntoRecord(); echo $object -> topic;
Previous section
Router object