Quantcast
Channel: Insane in the Main Frame
Viewing all articles
Browse latest Browse all 310

typo3 page view: manipulate the look of a content element

$
0
0

One of my customers wanted to see in the page view, which section_frame option they chose. So I found out there is a hook to manipulate the title and text below the grey bar. Add the following to the ext_localconf.php:

  1. $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem']['section_frame_name'] = 'Ophi\\OphiSomething\\Hook\\CustomPageLayoutView';

And in Ophi/OphiSomething/Classes/Hook there is the following hook file:

  1. namespace Ophi\OphiSomething\Hook;
  2. use TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface, TYPO3\CMS\Backend\View\PageLayoutView;
  3. class CustomPageLayoutView implements PageLayoutViewDrawItemHookInterface {
  4. /**
  5. * Preprocesses the preview rendering of a content element.
  6. *
  7. * @param PageLayoutView $parentObject Calling parent object
  8. * @param boolean $drawItem Whether to draw the item using the default functionalities
  9. * @param string $headerContent Header content
  10. * @param string $itemContent Item content
  11. * @param array $row Record row of tt_content
  12. * @return void
  13. */
  14. public function preProcess(\TYPO3\CMS\Backend\View\PageLayoutView &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row) {
  15. $headerContent = str_replace("</a>", " (Section Frame: " . ($row['section_frame']) . ")</a>", $headerContent);
  16. }
  17. }

And the result looks like this:
sectionframe
Thanks for helping me find the answer quickly to this Stackoverflow entry and this helpful page


Viewing all articles
Browse latest Browse all 310

Trending Articles