PHP code example of xima / xima-typo3-frontend-edit
1. Go to this page and download the library: Download xima/xima-typo3-frontend-edit library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
xima / xima-typo3-frontend-edit example snippets
declare(strict_types=1);
namespace Vendor\Package\EventListener;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use Xima\XimaTypo3FrontendEdit\Enumerations\ButtonType;
use Xima\XimaTypo3FrontendEdit\Event\FrontendEditDropdownModifyEvent;
use Xima\XimaTypo3FrontendEdit\Template\Component\Button;
class ModifyFrontendEditListener
{
public function __construct(protected readonly IconFactory $iconFactory, protected readonly UriBuilder $uriBuilder)
{
}
public function __invoke(FrontendEditDropdownModifyEvent $event): void
{
$contentElement = $event->getContentElement();
$menuButton = $event->getMenuButton();
// Example 1
// Append a custom button (after the existing edit_page button) for your plugin to e.g. edit the referenced entity
if ($contentElement['CType'] === 'list' && $contentElement['list_type'] === 'custom_plugin_name') {
$menuButton->appendAfterChild(new Button(
'Edit entity',
ButtonType::Link,
$this->uriBuilder->buildUriFromRoute(
'record_edit',
[
'edit' => [
'custom_entity' => [
$contentElement['custom_entity_uid'] => 'edit',
],
],
'returnUrl' => $event->getReturnUrl(),
],
)->__toString(),
$this->iconFactory->getIcon('content-idea', 'small')
), 'edit_page', 'edit_custom_entity');
}
// Example 2
// Remove existing buttons
$menuButton->removeChild('div_action');
$event->setMenuButton($menuButton);
}
}