首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TYPO3 -后台个性化盒子内容

TYPO3 -后台个性化盒子内容
EN

Stack Overflow用户
提问于 2012-10-11 02:22:50
回答 2查看 830关注 0票数 0

我已经构建了一个新的内容元素类型,当您查看后端时,在框中只能看到模块的名称。我想更改里面显示的信息。

我可以使用"header“字段,但有没有办法使用其他字段?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-11-12 02:14:32

两个答案

第一个答案

在那里显示的字段与列表模块中显示的字段相同。它是使用扩展模块ext_tables.php中的'ctrl‘在表的TCA中设置的

代码语言:javascript
复制
$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']

钩子将通过具有以下签名的函数调用:

代码语言:javascript
复制
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 (如果需要)设置为您想要显示的任何内容。

注意事项:

  1. 输出在跨度内,因此html中不允许有块元素。任何样式都必须在style属性中内联完成。
  2. 将在每个内容元素上调用该函数,因此您必须检查行的CType和(如果适用) list_type字段,以便只操作您自己的内容元素。

可以在"fed“扩展中找到一个示例。我希望这能帮到你。

票数 1
EN

Stack Overflow用户

发布于 2015-08-10 21:50:39

只是对adhominem answear #2进行了一点更新,这是正确的。

现在,在TYPO3 6.2及更高版本中,钩子类必须继承接口TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface

看起来像是“心爱”

代码语言:javascript
复制
<?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;将停止预览的默认渲染。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12825857

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档