General
Getting & Giving Support
Administration
Design
- Tut. - Layouts and Themes
- Tut. - Navigation cookbook
- Tut. - How To section
Reference Material
Plugin Development
- Tut. - Writing a plugin
- Ref. - List of Events
- Ref. - Enabling cron jobs
- Ref. - PHPDoc
Core Development
- Ref. - PHPDoc
Press information
Wolf CMS books section
url_start_with()
This is a simple conditional function which tests the current URI against a parameter supplied. If the paratmer matches the first element in the URI, it returns “true”; otherwise it returns “false”.
Examples
Consider the URL http://wolfsite.com/produce/fruit/apples.
url_start_with('produce')will return “true” onhttp://wolfsite.com/produce, and on
url_start_with('produce/fruit')will return- “false” on
http://wolfsite.com/produce, but - “true” on
http://wolfsite.com/produce/fruit, and on
url_start_with('fruit')will only return “false”.
Usage
This could be a useful function for using specific banner images in different sections of a website. For example, if there is a JPG image which correspsonds to the each top-level page in the site (like “produce”, above), it could be included this way:
//find the top-level page slug, and save it to a variable, e.g. $topSlug, then <img src="<?php echo (url_start_with($topSlug)) ? $topSlug : 'default'; ?>.jpg" />
This banner would then be used for all the child-pages (e.g. “fruit” and “apples” in the example above) for that top page.
See also the url_match() function.
