How can I preview a FE plugin hosted in a page module
I have developed TYPO3 extensions (6.2) with some FE plugins.
I need to change the plugin information that is displayed in the backend on a page.
Now only plugin title and name are displayed ...
I have used flexforms to customize the plugin and I would like to show some configuration in the "placeholder" plugin in the backend.
I remember reading several docs on how to do this a few years ago, but I can't find them anymore ...
Does anyone know the correct way to do this?
source to share
If I understand correctly, you are requesting a preview of the ContentElement. You need to use a cms/layout/class.tx_cms_layout.php
hook for this, here's a pretty nice gist
just two additions:
-
don't use the class
t3lib_extMgm
it removed since 7.x, you can only register this hook with:$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'][$_EXTKEY] = 'EXT:your_ext/Classes/Hooks/PageLayoutView.php:\Vendor\YourExt\Hooks\PageLayoutView';
-
Depending on how you registered the plugin (not mentioned), you might also need to check
$row['list_type']
as yours$row['CType']
might just be genericlist
.
Example of a class with a value from a FlexForm field
<?php
namespace Vendor\YourExt\Hooks;
class PageLayoutView implements \TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface {
public function preProcess(\TYPO3\CMS\Backend\View\PageLayoutView &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row) {
if ($row['CType'] == 'list' && $row['list_type'] == 'yourext_yourplugin') {
$drawItem = false;
$linkStart = '<a href="#" onclick="window.location.href=\'../../../alt_doc.php?returnUrl=%2Ftypo3%2Fsysext%2Fcms%2Flayout%2Fdb_layout.php%3Fid%3D' . $row['pid'] . '&edit[tt_content][' . $row['uid'] . ']=edit\'; return false;" title="Edit">';
$linkEnd = '</a>';
$headerContent =
$linkStart .
"<strong>Selected slides</strong>" .
$linkEnd;
$ffXml = \TYPO3\CMS\Core\Utility\GeneralUtility::xml2array($row['pi_flexform']);
$itemContent =
$linkStart .
$ffXml['data']['sDEF']['lDEF']['settings.myFlexField']['vDEF'] .
$linkEnd;
}
}
}
source to share