PHP code example of getdevflow / header-footer-builder

1. Go to this page and download the library: Download getdevflow/header-footer-builder 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/ */

    

getdevflow / header-footer-builder example snippets


$filters = \Qubus\EventDispatcher\ActionFilter\Filter::getInstance();

$ownsTheme = static function (\Vihzhuo\Contracts\ThemeContract $theme): bool {
    $folders = $theme instanceof \Vihzhuo\Theme
        ? $theme->getThemeFolders() : [$theme->getFolder()];
    return in_array(realpath(__DIR__), array_map('realpath', $folders), true);
};

$filters->addFilter('header.footer.slots', static function (array $slots, $theme) use ($ownsTheme): array {
    return $ownsTheme($theme)
        ? array_replace($slots, ['header' => ['my-navigation'], 'footer' => ['my-footer']])
        : $slots;
}, arguments: 2);

$filters->addFilter('header.footer.canvas.assets', static function (array $assets, $theme) use ($ownsTheme): array {
    if ($ownsTheme($theme)) {
        $assets['styles'] = array_merge($assets['styles'] ?? [], ['css/style.css']);
        $assets['scripts'] = array_merge($assets['scripts'] ?? [], ['js/theme.js']);
    }
    return $assets;
}, arguments: 2);

use Plugin\HeaderFooterBuilder\Support\Runtime;

$context = [...Runtime::context(), 'content_type' => 'article'];
echo Runtime::renderLocation('header', $context, $vihzhuo->getTheme());
// Render the page content here.
echo Runtime::renderLocation('footer', $context, $vihzhuo->getTheme());