Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
TYPO3 Fluid ViewHelper for creating Backend Edit Links for every Record
<?php
namespace Vendor\YourExt\ViewHelpers;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* ViewHelper to create a link to edit a note
* @internal
*/
class EditLinkViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper
{
/**
* @var string
*/
protected $tagName = 'a';
/**
* Initializes the arguments
*/
public function initializeArguments()
{
parent::initializeArguments();
$this->registerUniversalTagAttributes();
$this->registerArgument('uid', 'int', 'The record uid to edit', true);
$this->registerArgument('table', 'string', 'The table to edit', true);
}
/**
* @return string
*/
public function render()
{
$this->tag->addAttribute('href',BackendUtility::getModuleUrl(
'record_edit',
[
'edit[' . $this->arguments['table'] . '][' . $this->arguments['uid'] . ']' => 'edit',
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
]
));
$this->tag->setContent($this->renderChildren());
$this->tag->forceClosingTag(true);
return $this->tag->render();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.