I'm using Asgard CMS in one of my prjects.
I'm trying to print a menu with custom classes.
By defaut, {{ Menu::get('main') }} prints out the main menu with Bootstrap classes. But, I want to use different classes because of my theme.
In their documentation, they say that by creating a Presenteryou can do this. However, when I create a Presenter named CustomPresenter.php with a class named CustomPresenter that extends Pingpong/menus/Presenters/Presenter.php, place it under /vendor/xxx/ and calling it by {{ Menu::render('main', 'XXX/CustomPresenter') }}in my blade, Laravel gives Class 'XXX\CustomPresenter' not found error.
Here is the code I use in CustomPresenter:
namespace XXX;
use Pingpong\Menus\Presenters\Presenter;
class CustomPresenter extends Presenter
{
/**
* {@inheritdoc }
*/
public function getOpenTagWrapper()
{
return PHP_EOL . '<section class="top-bar-section">' . PHP_EOL;
}
/**
* {@inheritdoc }
*/
public function getCloseTagWrapper()
{
return PHP_EOL . '</section>' . PHP_EOL;
}
/**
* {@inheritdoc }
*/
public function getMenuWithoutDropdownWrapper($item)
{
return '<li'.$this->getActiveState($item).'><a href="'. $item->getUrl() .'">'.$item->getIcon().' '.$item->title.'</a></li>';
}
/**
* {@inheritdoc }
*/
public function getActiveState($item)
{
return \Request::is($item->getRequest()) ? ' class="active"' : null;
}
/**
* {@inheritdoc }
*/
public function getDividerWrapper()
{
return '<li class="divider"></li>';
}
/**
* {@inheritdoc }
*/
public function getMenuWithDropDownWrapper($item)
{
return '<li>
<a href="#" class="sf-with-ul">
'.$item->getIcon().' '.$item->title.'
</a>
<ul style="display: none;">
'.$this->getChildMenuItems($item).'
</ul>
</li>' . PHP_EOL;
;
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire