This is the ViewHelper i am using now:
/**
* A view helper for rendering the linktype
*
* = Examples =
*
* <code>
* {nc:linkType(parameter: link)}
* </code>
* <output>
* page, file, url, email, folder, unknown
* </output>
*/
class LinkTypeViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;
/**
* Initialize arguments
*/
public function initializeArguments()
{
$this->registerArgument('parameter', 'string', 'stdWrap.typolink style parameter string', true);
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return string Linktype (page, file, url, email, folder, unknown)
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
$parameter = $arguments['parameter'];
// workaround if parameter has _blank or other additional params
$arr = explode(' ',trim($parameter));
$firstparameter = $arr[0];
$linkService = GeneralUtility::makeInstance(LinkService::class);
$linkDetails = $linkService->resolve($firstparameter);
return $linkDetails['type'];
}
}
<f:link.typolink parameter="...">
? This can handle all 3 types. – Rudy Gnodde