PHP code example of braunstetter / template-hooks-bundle

1. Go to this page and download the library: Download braunstetter/template-hooks-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

braunstetter / template-hooks-bundle example snippets





namespace App\Twig;


use Braunstetter\TemplateHooks\Twig\TemplateHook;

class BreadcrumbsHook extends TemplateHook
{

    /**
     * @inheritDoc
     */
    public function render(): string
    {
        return $this->templating->render('hooks/breadcrumbs.html.twig', $this->context);
    }

    public function setTarget(): string|array
    {
        return 'app.cp.global-header';
        
        // it would be possible to register to multiple hooks
        // return ['app.cp.global-header', 'app.cp.global-sidebar'];
    }
}
html
{{ hook('app.cp.global-header') }}