kirby/branches/multilang/page.php
/**
   * Returns the slug for the page
   * The slug is the last part of the URL path
   * For multilang sites this can be translated with a URL-Key field
   * in the text file for this page.
   *
   * @param string $lang Optional language code to get the translated slug
   * @return string i.e. 01-projects returns projects
   */
Returns the slug for the page
The slug is the last part of the URL path
For multilang sites this can be translated with a URL-Key field
in the text file for this page.

@param string $lang Optional language code to get the translated slug
@return string i.e. 01-projects returns projects
Returns the slug for the page The slug is the last part of the URL path For multilang sites this can be translated with a URL - Key field in the text file for this page . @param string $lang Optional language code to get the translated slug @return string i . e . 01 - projects returns projects
public function slug($lang = null) {
    $default = $this->site->defaultLanguage->code;
    $current = $this->site->language->code;
    if(is_null($lang)) {
      if(isset($this->cache['slug'])) return $this->cache['slug'];
      if($current == $default) {
        return $this->cache['slug'] = $this->uid();
      }
      return $this->urlKey();
    } else {
      if($lang == $current) {
        return $this->slug();
      }
      if($lang == $default) {
        return $this->uid();
      }
      return $this->urlKey($lang);
    }
  }
public function slug ( $ lang = null ) { $ default = $ this -> site -> defaultLanguage -> code ; $ current = $ this -> site -> language -> code ; if ( is_null ( $ lang ) ) { if ( isset ( $ this -> cache [ 'slug' ] ) ) return $ this -> cache [ 'slug' ] ; if ( $ current == $ default ) { return $ this -> cache [ 'slug' ] = $ this -> uid ( ) ; } return $ this -> urlKey ( ) ; } else { if ( $ lang == $ current ) { return $ this -> slug ( ) ; } if ( $ lang == $ default ) { return $ this -> uid ( ) ; } return $ this -> urlKey ( $ lang ) ; } }
Returns the slug for the page
 The slug is the last part of the URL path
 For multilang sites this can be translated with a URL-Key field
 in the text file for this page.
Returns the slug for the page The slug is the last part of the URL path For multilang sites this can be translated with a URL - Key field in the text file for this page .
// get the slug for the current language // the current language's slug can be cached // if the current language is the default language // simply return the uid // get the translated url key  // if the passed language code is the current language code // we can simply return the slug method without a language code specified // the slug for the default language is just the name of the folder // get the translated url key 