Absolute url in presenter

Notice: This thread is very old.
dimkalinux
Member | 24
+
0
-

Nette 2.0.11

  1. How in presenter receive $baseUrl or how create absolute url in $this->link()? I found this way – but this ugly.
$url = $this->context->getByType('Nette\Http\IRequest')->getUrl();
$targetUrl = rtrim($url->getBaseUrl(), '/') . $this->link('Item:get');
  1. How correctly pass to presenter variables from config?
public function renderAdd()
{
    $nginxCacheLifetime = (string) $this->context->parameters["nginxCache"]["homepageLifetime"];
    $this->context->httpResponse->setHeader('X-Accel-Expires', $nginxCacheLifetime);
}
Oli
Member | 1215
+
+3
-
  1. I guess, it can work just with //, like: $this->link(‘//Item:get’). If it doesnt work, you should try, switch to absolute url in every links by
$this->absoluteUrls = true;

Presenter API: $absoluteUrls

dimkalinux
Member | 24
+
0
-

Oli, thanks — method with ‘//’ works.