Reputation: 25307
I've built a new content element type, and when you look in the backend, inside the box you can see the name of the module only. I'd like to change what information is show inside.
I could use the "header" field, but is there any way to use another field(s)?
Upvotes: 0
Views: 909
Reputation: 585
Just a little update to adhominem answear #2 which is correct.
Today in TYPO3 6.2 and above your hook class has to inherit the interface TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface
It´s looks like belove
<?php
namespace TYPO3\CMS\Backend\View;
/**
* Interface for classes which hook into PageLayoutView and do additional
* tt_content_drawItem processing.
*
* @author Oliver Hader <[email protected]>
*/
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
is boolean and send as reference and by changing it to $drawItem = false;
will stop the default rendering of the preview.
Upvotes: 0
Reputation: 1144
Two answers
The field that's displayed there is the same field that's displayed in the list module. It is set in the table's TCA using ['ctrl']['label'] in the extension's ext_tables.php
$TCA['tx_myext_mytable'] = array(
'ctrl' => array(
'title' => 'My Table'
'label' => 'name_of_the_field_to_display_as_header'
// end snip
If that is not enough for you, you can use a hook to display arbitrary HTML in the preview. The hook is called $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem']
.
The hook will be called with a function with this signature:
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
)
So all you have to do in that function is set the itemContent and, if you want, headerContent to whatever you want displayed.
Gotchas:
CType
and (if applicable) list_type
fields so
that you only manipulate your own content elements.An example can be found in the "fed" extension. I hope this helps.
Upvotes: 1