WEBサイト制作・アプリ開発・システム開発・ブランディングデザイン制作に関するご相談はお気軽にご連絡ください。
構想段階からじっくりとヒアリングし、お客様の課題にあわせたアプローチ手法でお客様の“欲しかった”をカタチにしてご提案いたします。
Blog スタッフブログ
EC-CUBE
システム開発
[EC-CUBE]プラグインで管理画面のメニューの追加
システム開発担当のTFです。
※EC-CUBE4系統対応
やり方
- 独自プラグインを作成する
- EccubeNav を継承した追加したいメニュー設定をしたファイルを作成する
- 表示用のtwigで menus と title と sub_title を設定する
- 独自プラグインをインストールし、有効化する
サンプル
<?php
namespace Plugin\TestPlugin;
use Eccube\Common\EccubeNav;
class Nav implements EccubeNav
{
/**
* @return array
*/
public static function getNav()
{
return [
// 受注の下にメニューを追加
'order' => [
'children' => [
'plugin_test_plugin' => [
'name' => 'テストプラグイン',
'url' => 'test_plugin',
],
],
],
];
}
}<?php
namespace Plugin\TestPlugin\Controller\Admin;
use Eccube\Controller\AbstractController;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Knp\Component\Pager\Paginator;
use Eccube\Common\EccubeConfig;
class TestController extends AbstractController
{
/**
* @var EccubeConfig
*/
protected $eccubeConfig;
private $errors = [];
/**
* ConfigController constructor.
*
* @param EccubeConfig $eccubeConfig
*/
public function __construct(
EccubeConfig $eccubeConfig
)
{
$this->eccubeConfig = $eccubeConfig;
}
/**
* @Route("/%eccube_admin_route%/test_plugin", name="test_plugin")
* @Template("@TestPlugin/admin/index.twig")
*/
public function index(Request $request)
{
return [
];
}
}{% extends '@admin/default_frame.twig' %}
{# メニュー選択時のアクティブ化の設定 #}
{% set menus = ['order', 'plugin_test_plugin'] %}
{# ページに表示されるタイトルとサブタイトルの設定 #}
{% block title %}テストプラグイン{% endblock %}
{% block sub_title %}受注管理{% endblock %}
{% block stylesheet %}
<style>
</style>
{% endblock stylesheet %}
{% block javascript %}
<script>
</script>
{% endblock javascript %}
{% block main %}
<div class="c-contentsArea__cols">
テストプラグインの画面
</div>
{% endblock %}