\Cairn_Rewrite

All rewrite rules are defined in a JSON file at static/urls.json

Summary

Methods
Properties
Constants
uri()
set_rules()
generate_rules()
$rules
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$_rules
$_replace
N/A

Properties

$rules

$rules

$_rules

$_rules

$_replace

$_replace

Methods

uri()

uri(array $request, string $view, boolean $unique, boolean $leavename) : string

Returns the permalink for a matching request. Every request defined in static/urls.json must be unque, so that there are not matching and duplicate urls for the same request.

Here is an example usage:

$year = mysql2date("Y", $post->post_date);
$month = mysql2date("n", $post->post_date);
$uri = Cairn_Rewrite::uri(array(
        'post_type' => 'post',
        'year' => $year,
        'monthnum' => $month,
        'name' => $post_name
    ),
    'default',
    true,
    false
);

Parameters

array $request

The request as associative array that will match a rule.

string $view

Name of the view for matching requests.

boolean $unique

Weither to return one or several matches.

boolean $leavename

Weither or not to leave the slug name.

Returns

string —

The permalink for the request.

set_rules()

set_rules( $uri)

Sets the rules to be used.

Parameters

$uri

generate_rules()

generate_rules()

Generates the rules and stored at self::$rules