Documentation

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

slug()

The slug is the form of the page's title used in the URL. It is produced by Wolf automatically when the page is created. For example, the “slug” for the “Articles” page is articles. Spaces are converted to hyphens: the title “Rhythm and Blues” will produce the slug rhythm-and-blues.

This value can be changed manually by editing it directly. When editing a page, click on the “Metadata” tab; “Slug” is the first field you see.

The slug of a given page can be retrieved with:

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

Notes

  • Home Page has no slug, not ever. For this reason, Wolf CMS does not offer a “slug” field in the metadata area of the root page.
  • Since the “slug” is used to form the page's URL, be careful which characters you use.
  • If the value of the slug is manually edited, it will retain the manually-edited value, even if the title of the page is changed.
  • If you wish to get the slug of a page with the slugs of all its ancestor pages, use the getUri() function.

Examples

find

The find() function uses the slug value to find a page. To find the Articles page, use $this->find('/articles/').

Using the slug in conditions

The slug is the best value to use if you want to ensure that code is used on a certain page, or to prevent some code from executing on a given page. For example, if you want to prevent some code from running on your “blog”-type pages (Articles), you could use something like this:

<?php if ($this->slug() != 'articles') {
  // do stuff you want to happen on all pages but the articles page
  code ... code ... code;
} ?>
 
functions/slug.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