Skip to content

Instantly share code, notes, and snippets.

@jsegars
Created September 24, 2013 03:58
Show Gist options
  • Save jsegars/6680212 to your computer and use it in GitHub Desktop.
Save jsegars/6680212 to your computer and use it in GitHub Desktop.
TYPO3 Neos ViewHelper for linking to nodes from with a plugin
<mypackage:link.node node="/sites/mysite/mypage">Click Me!</mypackage:link.node>
<?php
namespace My\Package\ViewHelpers\Link;
class NodeViewHelper extends \TYPO3\Neos\ViewHelpers\Link\NodeViewHelper {
/**
* Render the link.
*
* @param mixed $node A TYPO3\TYPO3CR\Domain\Model\NodeInterface object or a string 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
* @param string $baseNodeName The name of the base node inside the TypoScript context to use for the ContentContext or resolving relative paths
* @return string The rendered link
*/
public function render($node = NULL, $format = NULL, $absolute = FALSE, $baseNodeName = 'documentNode') {
if (is_string($node) && $this->controllerContext->getRequest()->getInternalArgument('__documentNode')) {
$node = $this->controllerContext->getRequest()->getInternalArgument('__documentNode')->getNode($node);
}
return parent::render($node, $format, $absolute, $baseNodeName);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment