Contao\PageModel::getFrontendUrl PHP Method

getFrontendUrl() public method

Generate a front end URL
public getFrontendUrl ( string $strParams = null, string $strForceLang = null ) : string
$strParams string An optional string of URL parameters
$strForceLang string Force a certain language
return string An URL that can be used in the front end
    public function getFrontendUrl($strParams = null, $strForceLang = null)
    {
        if ($strForceLang !== null) {
            @trigger_error('Using PageModel::getFrontendUrl() with $strForceLang has been deprecated and will no longer work in Contao 5.0.', E_USER_DEPRECATED);
        }
        $this->loadDetails();
        $objUrlGenerator = \System::getContainer()->get('contao.routing.url_generator');
        $strUrl = $objUrlGenerator->generate(($this->alias ?: $this->id) . $strParams, array('_locale' => $strForceLang ?: $this->rootLanguage, '_domain' => $this->domain, '_ssl' => (bool) $this->rootUseSSL));
        // Make the URL relative to the base path
        if (0 === strpos($strUrl, '/')) {
            $strUrl = substr($strUrl, strlen(\Environment::get('path')) + 1);
        }
        $strUrl = $this->applyLegacyLogic($strUrl, $strParams);
        return $strUrl;
    }