Documentation

Light-weight, fast, simple and powerful!
 
Translations of this page?:
Table of Contents

url_match()

This is a simple conditional function which tests the current URI against a parameter supplied. If they match, it returns “true”; otherwise it returns “false”.

Example

A useful example is found in the default “header” snippet that is created when Wolf is installed. In the navigation code, this is the first entry in the <ul> list:

<li><a<?php echo url_match('/') ? ' class="current"': ''; ?> href="<?php echo URL_PUBLIC; ?>">Home</a></li>

This hard-sets the “Home” link in the navigation; the url_match() function provides the test for whether the homepage is current, and echoes the class="current" for styling the anchor if the test is successful.

Notes

All elements of the URI must be matched for “true” to be returned. For example, with the URL http://wolfsite.com/page/child-page, the test url_match('child-page') will return false, but url_match(page/child-page) will return true.

See also the url_start_with() function.

 
functions/url_match.txt · Last modified: 2011-09-12 00:46 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license:GNU Free Documentation License 1.2
Copyright 2010 wolfcms.org / design by yello studio / Wolf CMS Inside