help with addRoute

20 views
Skip to first unread message

Battistella, Marco

unread,
Apr 2, 2015, 12:49:46 PM4/2/15
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

unread,
Apr 2, 2015, 1:56:05 PM4/2/15
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
Reply all
Reply to author
Forward
0 new messages