#typo3

Custom content post procession for TYPO3

Compress or pretty print HTML output by your own

There are many HTML compression extensions for TYPO3 in the TER. Many of them aren't maintained anymore or just have a huge overhead, you will mostly not need for anything. So why not build a content compression by your own?

It's pretty easy to implement. Basically it just require the use of two Hooks from tslib/class.tslib_fe.php. The Hooks are called contentPostProc-all and contentPostProc-output. The first one handles normal pages with cached output, the second one does the same, just for uncached pages with COA or USER_INT objects. This Hooks will be bind to a class and function of your choice in ext_localconf.php of your extension.

read more ...
Share:

How to create an internal URI in TYPO3

Sometimes you want to generate TYPO3 internal URIs programmatically. Now you could try to create the URL manually on your own, or use the UriBuilder class. This handy tool is pretty neat to create any kind of internal URI. In a controller this class is available by $this->getControllerContext()->getUriBuilder(). If you want to use the UriBuilder somewhere else, you need to load an instance of the class by the ObjectManager.

$objectManager = 
  GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager\ObjectManager::class);
$uriBuilder =
  $objectManager->get(\TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder::class);

When you have access to an instance of the builder, it's pretty straight forward from now on. The class has a bunch of simple setters, to control the generation of the URI. Best practice is to reset all the options of the builder on start of every new URI creation.

read more ...
Share:

Overwrite the default layout in TYPO3

I'm pretty sure that many people search for this thing already. So did I. It took me quite a lot time to figure out, how to overwrite the default template in TYPO3 8.7. This layout comes with some annoying wrappings, like the new frames. So you may want to remove them too. When you know how, it's really easy to do. Just add a small part to your TypoScript setup.

lib {
  contentElement {
    layoutRootPaths {
      10 = EXT:page/Resources/Private/Layouts
    }
  }
}
read more ...
Share: