original_string: public function url($include_host = false, $canonical = false, $include_base = true, $raw_route = false)
      {
          // Override any URL when external_url is set
          if (isset($this->external_url)) {
              return $this->external_url;
          }
  
          $grav = Grav::instance();
  
          /** @var Pages $pages */
          $pages = $grav['pages'];
  
          /** @var Config $config */
          $config = $grav['config'];
  
          // get base route (multi-site base and language)
          $route = $include_base ? $pages->baseRoute() : '';
  
          // add full route if configured to do so
          if (!$include_host && $config->get('system.absolute_urls', false)) {
              $include_host = true;
          }
  
          if ($canonical) {
              $route .= $this->routeCanonical();
          } elseif ($raw_route) {
              $route .= $this->rawRoute();
          } else {
              $route .= $this->route();
          }
  
          /** @var Uri $uri */
          $uri = $grav['uri'];
          $url = $uri->rootUrl($include_host) . '/' . trim($route, '/') . $this->urlExtension();
  
          // trim trailing / if not root
          if ($url !== '/') {
              $url = rtrim($url, '/');
          }
  
          return Uri::filterPath($url);
      }
code: public function url($include_host = false, $canonical = false, $include_base = true, $raw_route = false)
      {
          // Override any URL when external_url is set
          if (isset($this->external_url)) {
              return $this->external_url;
          }
  
          $grav = Grav::instance();
  
          /** @var Pages $pages */
          $pages = $grav['pages'];
  
          /** @var Config $config */
          $config = $grav['config'];
  
          // get base route (multi-site base and language)
          $route = $include_base ? $pages->baseRoute() : '';
  
          // add full route if configured to do so
          if (!$include_host && $config->get('system.absolute_urls', false)) {
              $include_host = true;
          }
  
          if ($canonical) {
              $route .= $this->routeCanonical();
          } elseif ($raw_route) {
              $route .= $this->rawRoute();
          } else {
              $route .= $this->route();
          }
  
          /** @var Uri $uri */
          $uri = $grav['uri'];
          $url = $uri->rootUrl($include_host) . '/' . trim($route, '/') . $this->urlExtension();
  
          // trim trailing / if not root
          if ($url !== '/') {
              $url = rtrim($url, '/');
          }
  
          return Uri::filterPath($url);
      }
code_tokens: public function url ( $ include_host = false , $ canonical = false , $ include_base = true , $ raw_route = false ) { // Override any URL when external_url is set if ( isset ( $ this -> external_url ) ) { return $ this -> external_url ; } $ grav = Grav :: instance ( ) ; /** @var Pages $pages */ $ pages = $ grav [ 'pages' ] ; /** @var Config $config */ $ config = $ grav [ 'config' ] ; // get base route (multi-site base and language) $ route = $ include_base ? $ pages -> baseRoute ( ) : '' ; // add full route if configured to do so if ( ! $ include_host && $ config -> get ( 'system.absolute_urls' , false ) ) { $ include_host = true ; } if ( $ canonical ) { $ route .= $ this -> routeCanonical ( ) ; } elseif ( $ raw_route ) { $ route .= $ this -> rawRoute ( ) ; } else { $ route .= $ this -> route ( ) ; } /** @var Uri $uri */ $ uri = $ grav [ 'uri' ] ; $ url = $ uri -> rootUrl ( $ include_host ) . '/' . trim ( $ route , '/' ) . $ this -> urlExtension ( ) ; // trim trailing / if not root if ( $ url !== '/' ) { $ url = rtrim ( $ url , '/' ) ; } return Uri :: filterPath ( $ url ) ; }
docstring: Gets the url for the Page.
  
  @param bool $include_host Defaults false, but true would include http://yourhost.com
  @param bool $canonical    True to return the canonical URL
  @param bool $include_base Include base url on multisite as well as language code
  @param bool $raw_route
  
  @return string The url.
docstring_tokens: Gets the url for the Page .