Route
Holds information for URLs, redirecting, etc.
Summary
| Route | Holds information for URLs, redirecting, etc. |
| Variables | |
| $action | The current action. |
| $try | An array of (string) actions to try until one doesn’t return false. |
| $ajax | Shortcut to the AJAX constant (useful for Twig). |
| $success | Did Route.init call a successful route? |
| $feed | Is the visitor requesting a feed? |
| $controller | The Route’s Controller. |
| Functions | |
| __construct | Parse the URL to determine what to do. |
| init | Begin running Controller actions until one of them doesn’t return false. |
| url | Attempts to change the specified clean URL to a dirty URL if clean URLs is disabled. Use this for linking to things. The applicable URL conversions are passed through the parse_urls trigger. |
| add | Adds a route to Chyrp. Only needed for actions that have more than one parameter. For example, for /tags/ you won’t need to do this, but you will for /tag/tag-name/. |
| route | Removes a route added by add. |
| current | Returns a singleton reference to the current class. |
$success
public $success
Did Route.init call a successful route?
url
| public function url( | $url, | |||
| $use_chyrp_url | = | false | ) |
Attempts to change the specified clean URL to a dirty URL if clean URLs is disabled. Use this for linking to things. The applicable URL conversions are passed through the parse_urls trigger.
Parameters
| $url | The clean URL. |
Returns
| Clean URL | if $config->clean_urls is set to true. |
| Dirty URL | if $config->clean_urls is set to false. |
add
| public function add( | $path, | |
| $action | ) |
Adds a route to Chyrp. Only needed for actions that have more than one parameter. For example, for /tags/ you won’t need to do this, but you will for /tag/tag-name/.
Parameters
| $path | The path to add. Wrap variables with parentheses, e.g. “tag/(name)/”. |
| $action | The action the path points to. |
See Also
<remove>