我在我的一个项目中使用 Asgard CMS。
我正在尝试打印带有自定义类的菜单。
默认情况下,{{ Menu::get('main') }}
使用 Bootstrap 类打印出主菜单。但是,由于我的主题,我想使用不同的类。
在他们的文档中,他们说通过创建一个Presenter
你可以做到这一点。但是,当我创建一个名为extendsCustomPresenter.php
的类的 Presenter 时,将它放在下面并在我的刀片中调用它时,Laravel 给出Class 'XXX\CustomPresenter' not found错误。CustomPresenter
Pingpong/menus/Presenters/Presenter.php
/vendor/xxx/
{{ Menu::render('main', 'XXX/CustomPresenter') }}
这是我在 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;
;
}
}