help with addRoute

閲覧: 20 回
最初の未読メッセージにスキップ

Battistella, Marco

未読、
2015/04/02 12:49:462015/04/02
To: omek...@googlegroups.com
Hi,
I’m working on a plugin that will add a few pages.
I’m looking at how the simple pages plugin implements this functionality but i can’t find specific documentation on how to use addRoute.

in particular, i’m attempting to use as an example this code taken form the simple pages plugin:

$router->addRoute(
'simple_pages_show_page_' . $page->id,
new Zend_Controller_Router_Route(
$page->slug,
array(
'module' => 'simple-pages',
'controller' => 'page',
'action' => 'show',
'id' => $page->id
)
)
);

when added this way:

$router->addRoute(
‘my_plugin_show_page’,
new Zend_Controller_Router_Route(
‘my_plugin/my_page’,
array(
'module' => ‘my_plugin',
'controller' => ‘page',
'action' => 'show',
)
)
);


it returns a 404 error
but if i remove the ‘controller’ => ‘page’ line it returns the home page.

So i’m confused, what is the controller? How can I use it?

Thank you in advance.
MB


Patrick Murray-John

未読、
2015/04/02 13:56:052015/04/02
To: omek...@googlegroups.com
It's probably that the controller and action for your plugin aren't set
up right. The way SimplePages does it, everything goes to the controller
in /controllers/PageController.php (from the 'controller' => 'page' info
in the array), and the function in it showAction(). That then digs up
the actual page data from the id and displays it.

So, chances are that you'll want to look at how your controllers are set
up, and compare with SimplePages.

Also, what kinds of features are in your pages? It might be that just
using SimplePages and maybe creating special shortcodes for your
functionality would be quicker and easier.

Patrick
全員に返信
投稿者に返信
転送
新着メール 0 件