我已经构建了一个新的内容元素类型,当您查看后端时,在框中只能看到模块的名称。我想更改里面显示的信息。
我可以使用"header“字段,但有没有办法使用其他字段?

发布于 2012-11-12 02:14:32
两个答案
第一个答案
在那里显示的字段与列表模块中显示的字段相同。它是使用扩展模块ext_tables.php中的'ctrl‘在表的TCA中设置的
$TCA['tx_myext_mytable'] = array(
'ctrl' => array(
'title' => 'My Table'
'label' => 'name_of_the_field_to_display_as_header'
// end snip第二个答案
如果这还不够,您可以使用钩子在预览中显示任意HTML。这个钩子叫做$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem']。
钩子将通过具有以下签名的函数调用:
public function preProcess(
tx_cms_layout &$parentObject, // parent object
&$drawItem, // i have no idea what this is
&$headerContent, /* the content of the header
(the grey bar in the screenshot i think) */
&$itemContent, /* the content of the preview
(the white area in your screenshot */
array &$row // the content element's record
)因此,您在该函数中所要做的就是将itemContent和headerContent (如果需要)设置为您想要显示的任何内容。
注意事项:
CType和(如果适用) list_type字段,以便只操作您自己的内容元素。可以在"fed“扩展中找到一个示例。我希望这能帮到你。
发布于 2015-08-10 21:50:39
只是对adhominem answear #2进行了一点更新,这是正确的。
现在,在TYPO3 6.2及更高版本中,钩子类必须继承接口TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface
看起来像是“心爱”
<?php
namespace TYPO3\CMS\Backend\View;
/**
* Interface for classes which hook into PageLayoutView and do additional
* tt_content_drawItem processing.
*
* @author Oliver Hader <oliver@typo3.org>
*/
interface PageLayoutViewDrawItemHookInterface {
/**
* Preprocesses the preview rendering of a content element.
*
* @param \TYPO3\CMS\Backend\View\PageLayoutView $parentObject Calling parent object
* @param boolean $drawItem Whether to draw the item using the default functionalities
* @param string $headerContent Header content
* @param string $itemContent Item content
* @param array $row Record row of tt_content
* @return void
*/
public function preProcess(\TYPO3\CMS\Backend\View\PageLayoutView &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row);
}&$drawItem是布尔值,并作为引用发送,通过将其更改为$drawItem = false;将停止预览的默认渲染。
https://stackoverflow.com/questions/12825857
复制相似问题