Framework Docs
URL Helpers
URL Helpers
The Url class collects every URL-related utility: redirects, canonical URL generation, SEO slug creation, breadcrumb rendering, and request-info helpers.
Namespace: Wojo\Core\Url
SEO & Slug
| Method | Signature | Description |
|---|---|---|
| doSeo() | static doSeo(string $string, int $max_len = 60): string |
Convert a title to a URL-safe slug (lowercase, hyphens) |
| parseSearchFilters() | static parseSearchFilters(bool $wild = false): array |
Parse filter segments from the URL into an associative array |
| buildUrl() | static buildUrl(string $key, string $value, string $option = 'add'): string |
Toggle, add, or remove a query parameter in the current URL |
| buildQuery() | static buildQuery(): string |
Serialize current GET params back to a query string |
// Create a slug
$slug = Url::doSeo('Hello World! This is a Test'); // → 'hello-world-this-is-a-test'
// Get the current page's URL segment (e.g. /posts/my-article → 'my-article')
$slug = Url::segment($this->segments, 1);
// Build a filter toggle URL (for filter bars)
$href = Url::buildUrl('status', 'active'); // adds ?status=active
$href = Url::buildUrl('status', 'active', 'remove'); // removes the param
Breadcrumbs
| Method | Signature | Description |
|---|---|---|
| renderBreadcrumbs() | static renderBreadcrumbs(array $crumbs, string $divider = '/'): string |
Render an HTML breadcrumb trail. The last item is the active (non-linked) crumb. |
$crumbs = [
'Home' => Url::url('/'),
'Blog' => Url::url('/blog'),
'Post' => null, // null = current page, rendered as plain text
];
echo Url::renderBreadcrumbs($crumbs, '>');
// → <nav ...><a href="...">Home</a> > <a href="...">Blog</a> > Post</nav>
Other Helpers
| Method | Description |
|---|---|
| getIP(): string | Return the visitor's IP address (checks proxies) |
| segment(array $segs, int $id): string | Return the Nth URL segment (0-indexed) or empty string |
| isActiveSegment(): bool | Check if the current URL matches a given segment |
| setActiveAria(): string | Return aria-current="page" when a segment matches (for nav accessibility) |