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


The url() function gives access to the URL of the current page. It does not take any parameters. If, for example, the current page was the “Articles” page, then

<?php echo $this->url(); ?>

returns the value:

See also: urlById()

Usage notes

URLs of pages that are not current

To return the URL of a page that is not current, use the find function. This code:

<?php echo $this->find('articles')->url(); ?>

returns:, from anywhere in the site.

Using a Suffix

If you have set up Wolf to use a URL suffix to simulate static pages (e.g., ”.html”), then you might run into problems when embedding url() in a concatenated string. So, for example, in the “sidebar” code of the default “Articles” page, this code:

<?php echo $this->url() .'/'. $date . URL_SUFFIX; ?>

produces an error, because ”.html” is embedded before the $date. In this case, omit the suffix by using the “false” flag:

<?php echo $this->url(false) .'/'. $date . URL_SUFFIX; ?>

This will make “url” omit the unwanted suffix.

Creating links

Although url() can of course be used for creating links, there is a specialized function that is normally the preferred way of doing this: see the documentation on the link() function.

functions/url.txt · Last modified: 2013-05-04 14:49 by David
Except where otherwise noted, content on this wiki is licensed under the following license:GNU Free Documentation License 1.2
Copyright 2010 / design by yello studio / Wolf CMS Inside