Created
September 24, 2013 03:58
-
-
Save jsegars/6680212 to your computer and use it in GitHub Desktop.
TYPO3 Neos ViewHelper for linking to nodes from with a plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<mypackage:link.node node="/sites/mysite/mypage">Click Me!</mypackage:link.node> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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