/** * Render the Uri. * * @param mixed $node A node object or a node path * @param string $format Format to use for the URL, for example "html" or "json" * @param boolean $absolute If set, an absolute URI is rendered * @return string The rendered URI */ public function render($node = NULL, $format = NULL, $absolute = FALSE) { $request = $this->controllerContext->getRequest()->getMainRequest(); $uriBuilder = new \TYPO3\FLOW3\Mvc\Routing\UriBuilder(); $uriBuilder->setRequest($request); if ($node === NULL) { $node = $this->nodeRepository->getContext()->getCurrentNode(); } if ($format === NULL) { $format = $request->getFormat(); } $uri = $uriBuilder->reset()->setCreateAbsoluteUri($absolute)->setFormat($format)->uriFor('show', array('node' => $node), 'Frontend\\Node', 'TYPO3.TYPO3'); return $uri; }
/** * Render a link to a specific module * * @param string $path Target module path * @param string $action Target module action * @param array $arguments Arguments * @param string $section The anchor to be added to the URI * @param string $format The requested format, e.g. ".html" * @param array $additionalParams additional query parameters that won't be prefixed like $arguments (overrule $arguments) * @param boolean $addQueryString If set, the current query parameters will be kept in the URI * @param array $argumentsToBeExcludedFromQueryString arguments to be removed from the URI. Only active if $addQueryString = TRUE * @return string The rendered link * @throws \TYPO3\Fluid\Core\ViewHelper\Exception */ public function render($path, $action = NULL, $arguments = array(), $section = '', $format = '', array $additionalParams = array(), $addQueryString = FALSE, array $argumentsToBeExcludedFromQueryString = array()) { $mainRequest = $this->controllerContext->getRequest()->getMainRequest(); $uriBuilder = new \TYPO3\FLOW3\Mvc\Routing\UriBuilder(); $uriBuilder->setRequest($mainRequest); $modifiedArguments = array('module' => $path); if ($arguments !== array()) { $modifiedArguments['moduleArguments'] = $arguments; } if ($action !== NULL) { $modifiedArguments['moduleArguments']['@action'] = $action; } try { $uri = $uriBuilder->reset()->setSection($section)->setCreateAbsoluteUri(TRUE)->setArguments($additionalParams)->setAddQueryString($addQueryString)->setArgumentsToBeExcludedFromQueryString($argumentsToBeExcludedFromQueryString)->setFormat($format)->uriFor('index', $modifiedArguments, 'Backend\\Module', 'TYPO3.TYPO3'); $this->tag->addAttribute('href', $uri); } catch (\TYPO3\FLOW3\Exception $exception) { throw new \TYPO3\Fluid\Core\ViewHelper\Exception($exception->getMessage(), $exception->getCode(), $exception); } $this->tag->setContent($this->renderChildren()); $this->tag->forceClosingTag(TRUE); return $this->tag->render(); }