[TYPO3-english] Re: problem after update to 6.2 with extension
andreas
an.pfeiffer at gmail.com
Fri Mar 28 10:34:05 CET 2014
thank you.
i may wrote wrong.
in the regular controller for actions or repositories to call other it works fine with inject. really nice.
but i have a problem in a hook.
---
namespace Ce\CeContent\Hooks;
class DrawItem implements \TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface {
/**
* @var \TYPO3\CMS\Extbase\Object\ObjectManager
*/
protected $objectManager;
/**
* Constructor
*/
public function __construct() {
$this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager');
}
/**
* Disable rendering restrictions for contentelements
*
* @param \TYPO3\CMS\Backend\View\PageLayoutView $parentObject
* @param $drawItem
* @param $headerContent
* @param $itemContent
* @param array $row
* @return void
*/
public function preProcess(\TYPO3\CMS\Backend\View\PageLayoutView $parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row) {
if(preg_match('/cecontent/', $row["CType"])) {
$drawItem = false;
$type = str_replace('cecontent_', '', $row["CType"]);
$template = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:ce_content/Resources/Private/Templates/Backend/CMSLayoutHook/' . ucfirst($type) . '.html');
$content = $this->getContent($type, $row["uid"]);
$itemContent = $this->getItem($template, $content);
}
}
/**
* get item
*
* @param \string $template
* @param \array $content
* @return $item
*/
private function getItem($template, $content) {
if(is_file($template) && count($content)) {
// template fluid - laden
$fluidRenderer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Fluid\View\StandaloneView');
$fluidRenderer->setFormat('html');
$fluidRenderer->setTemplatePathAndFilename($template);
$fluidRenderer->setLayoutRootPath(dirname($template));
// template fluid - mappen
$fluidRenderer->assign('content', $content);
return $fluidRenderer->render();
}
}
/**
* get content
*
* @param \string $type
* @param \int $uid
* @return $content
*/
private function getContent($type, $uid) {
// inject funktioniert nicht, deshalb über objectmanager
$repository = $this->objectManager->get('Ce\\CeContent\\Domain\\Repository\\' . ucfirst($type) . 'Repository');
$content = $repository->findByTtContentUid($uid);
return $content;
}
}
---
i use this as preview for own contentelements in the page-view an call this file in localconf.php
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'][] = 'EXT:' . $_EXTKEY . '/Classes/Hooks/CMSLayoutHook.php:Ce\\CeContent\\Hooks\\DrawItem';
no matter what i try to inject if repository or the StandaloneView for fluid - does not work.
this problem is solved with your help by the objectmanager.
so in general it works.
thank you
More information about the TYPO3-english
mailing list