kirby/branches/multilang/page.php
/**
   * Returns the full url for the page
   *
   * @param string $lang Optional language code to get the URL for that specific language on multilang sites
   * @return string
   */
Returns the full url for the page
@param string $lang Optional language code to get the URL for that specific language on multilang sites
@return string
Returns the full url for the page @param string $lang Optional language code to get the URL for that specific language on multilang sites @return string
public function url() {
    $args = func_get_args();
    $lang = array_shift($args);
    if(is_null($lang)) {
      $lang = $this->site->language->code;
    }
    if($this->isHomePage()) {
      $url = $this->site->url($lang);
      if($this->site->language->host() !== $this->site->language($lang)->host()) {
        $url = url::build(['query' => ['language' => 'switch']], $url);
      }
      return $url;
    } else if($this->parent->isHomePage()) {
      return $this->site->url($lang) . '/' . $this->parent->slug($lang) . '/' . $this->slug($lang);
    } else {
      return $this->parent->url($lang) . '/' . $this->slug($lang);
    }
  }
public function url ( ) { $ args = func_get_args ( ) ; $ lang = array_shift ( $ args ) ; if ( is_null ( $ lang ) ) { $ lang = $ this -> site -> language -> code ; } if ( $ this -> isHomePage ( ) ) { $ url = $ this -> site -> url ( $ lang ) ; if ( $ this -> site -> language -> host ( ) !== $ this -> site -> language ( $ lang ) -> host ( ) ) { $ url = url :: build ( [ 'query' => [ 'language' => 'switch' ] ] , $ url ) ; } return $ url ; } else if ( $ this -> parent -> isHomePage ( ) ) { return $ this -> site -> url ( $ lang ) . '/' . $ this -> parent -> slug ( $ lang ) . '/' . $ this -> slug ( $ lang ) ; } else { return $ this -> parent -> url ( $ lang ) . '/' . $ this -> slug ( $ lang ) ; } }
Returns the full url for the page
 @param string $lang Optional language code to get the URL for that specific language on multilang sites
 @return string
Returns the full url for the page @param string $lang Optional language code to get the URL for that specific language on multilang sites @return string
// for multi language sites every url needs // to be treated specially to make sure each uid is translated properly // and language codes are prepended if needed // get the current language // Kirby is trying to remove the home folder name from the url // append a query param if the new language is on another domain