Parameters
- a (optional) – name of the action to set to be rendered (used only by core)
Description
This function is called by index.php to set the initial action to be rendered
Example(s)
echo "The action called was " . PathMap::action();
The /app/PathMap.class.php file extends the /core/BaseMapping.class.php file. The /core/BaseMapping.class.php file contains the base functionality for path mapping which includes setting the controller, action, render_controller, and render_action variables. The /core/BaseMapping.class.php should never be edited! The /app/PathMap.class.php file is provided to give developers access to the functionality of the /core/BaseMapping.class.php file and so that customizations can be made to the mapping functionality by overriding an inherited class (namely BaseMapping::map_path()) and custom functions to help with mapping.
Functions that have been moved from /core/Fabriq.class.php to /core/BaseMapping.class.php include:
Parameters
Description
This function is called by index.php to set the initial action to be rendered
Example(s)
echo "The action called was " . PathMap::action();
Added in version: 0.8
Return type: string
Parameters
Description
The PathMap::arg() function is the getter/setter for arguments in the query arguments variable. If a second parameter is passed in, the argument at the given index is set to the given value of the second parameter.
Example(s)
// example 1 - get an argument echo PathMap::arg(2); // example 2 - set an argument PathMap::arg(2, $id);
Added in version: 0.8
Return type: object
Description
This function returns the base path of the application that is stored in the config file. The results of the function can be used for building paths when not using Fabriq::link_to().
Example(s)
// example displaying the base path to the output echo PathMap::base_path();
Added in version: 0.8
Return type: string
Description
The PathMap::build_path() function is used to build a path to be used in Fabriq applications. The function can be used when building a path for the action attribute of a form element in a view.
Example(s)
<form method="post" action="<?php echo PathMap::build_path('blog', 'create'); ?>">
<!-- form code -->
</form>
Added in version: 0.8
Return type: string
Description
Returns whether or not the Fabriq application is using clean URLs based on the setting in the configuration file.
Example(s)
if (PathMap::clean_urls()) { // tasks to perform if using clean URLs }
Added in version: 0.8
Return type: boolean
Description
Returns a string version of the boolean for whether or not the Fabriq application is using clean URLs based on the setting in the configuration file.
Example(s)
echo "This site uses clean URLs: " . PathMap::clean_urls_str();
Added in version: 0.8
Return type: string
Parameters
Description
This function is called by index.php to set the initial controller to be rendered
Example(s)
echo "The controller called was " . PathMap::controller();
Added in version: 0.8
Return type: string
Description
The PathMap::map_path() function breaks down the input URL and determines the controller and action to attempt to render. If you wish to use the default mapping functionality, the file can be left along. To add custom functionality, follow the example below and make adjustments as necessary. NOTE: you should only edit this function in the /app/PathMap.class.php file and NOT in the /core/BaseMapping.class.php file that /app/PathMap.class.php extends. The /core/BaseMapping.class.php file is a core file and should never be edited.
Example(s)
// example custom mapping functionality class PathMap extends BaseMapping { // other function in Path Map class public function map_path() { parent::map_path(); // custom mapping of profile controller // To view user profiles, url is in format example.com/profile/username // the app needs it in the format example.com/profile/read/username switch(self::controller) { case 'profile': self::arg(2, self::arg(1)); self::arg(1, 'read'); self::action('read'); break; } } // other function in Path Map class }
Added in version: 0.8
Parameters
Description
This function acts as a getter and setter for the render action to be executed. If the value is different from action, then the render action is executed after the action. If NULL is passed in, the render action name is returned.
Example(s)
echo "The render action being executed is: " . PathMap::render_action();
Added in version: 0.8
Return type: string
Parameters
Description
This function acts as a getter and setter for the render controller to be executed. If the value is different from controller, then the render action in the render controller is executed after the action in the controller. If NULL is passed in, the render controller name is returned.
Example(s)
echo "The render controller that may execute the render action is: " . PathMap::render_controller();
Added in version: 0.8
Return type: string