PHP code example of tatter / menus

1. Go to this page and download the library: Download tatter/menus 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/ */

    

tatter / menus example snippets


class MainMenu extends \Tatter\Menus\Menu
{
	public function __toString(): string
	{
		return $this->builder
			->link(site_url('/'), 'Home')
			->link(site_url('/about'), 'About')
			->html('<hr>')
			->link(site_url('/contact'), 'Contact')
			->render();
	}
}

class FruitMenu extends \Tatter\Menus\Menu
{
	public function __toString(): string
	{
		return view('menus/fruit', ['active' => 'banana']);
	}
}

 namespace App\Filters;

use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Tatter\Menus\Filters\MenusFilter;

class MainMenuFilter extends MenusFilter
{
	public function after(RequestInterface $request, ResponseInterface $response, $arguments = null): ?ResponseInterface
	{
		return parent::after($request, $response, ['main', 'fruit']);
	}
}