2017-11-11 6 views
0

PanelAdminという名前の管理パネルプラグインがあります。 私が直接PanelAdminを呼び出すために、それは上記の図を示しているが、今、私必要がありますしたいテンプレート/トピックス/ index.ctpcakephpのURLからプラグインコントローラを呼び出す方法3

<h1>Blog topics</h1> 

<p><?= $this->Html->link('Add Topic', ['action' => 'add']) ?></p> 

<table> 

    <tr> 

     <th>Id</th> 

     <th>Title</th> 

     <th>Created</th> 

     <th>Actions</th> 

    </tr> 

の内側に見るこれは、これはトピックであるCategoriesController.php

<?php 

namespace PanelAdmin\Controller; 

use Cake\Controller\Controller; 
use Cake\ORM\TableRegistry; 

class CategoriesController extends AppController 
{ 
public function initialize() 

    { 

     parent::initialize(); 

     $this->loadComponent('Flash'); // Include the FlashComponent 

    } 

public function index() 

    { 

     $this->set('topics', $this->categories->find('all')); 

    } 

    } 

?> 

ですそれは私がhttp://localhost/multi_shopping/PanelAdminこのURLを打ったとき、それは、プラグインフォルダに検索したいメインのsrcフォルダ内の検索

Error: CategoriesController could not be found. 

:次のエラーを得ました。

答えて

0

あなたが/ PanelAdmin

$routes->connect('/PanelAdmin', [ 
    'plugin' => 'PanelAdmin', 
    'controller' => 'Categories', 
    'action' => 'index' 
]); 
+0

として、あなたのコントローラがアクセスできるようになります、URLにプラグインコントローラにアクセスするには、プラグイン内のルートを定義する必要はありませんプラグインPanelAdminのroutes.phpファイルまたはメインのroutes.phpファイル – user3653474

0

に最初にあなたのプラグインがhttps://book.cakephp.org/3.0/en/plugins.html#plugin-configurationにロードされていることを確認し、接続ルートを追加する必要があります。

あなたはCakePHPのデフォルトのルートが自動的にこれをして追加する/パネル管理者/カテゴリ

関連する問題