Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Route configuration is (yet another thing which is) completely undocumented #46

Open
teo1978 opened this issue Sep 21, 2019 · 1 comment

Comments

@teo1978
Copy link

teo1978 commented Sep 21, 2019

Here's another concrete example of the utter insufficiency of the Omeka documentation.

I'll explain what I want to do so that you can understand what's missing in the documentation that would allow me to learn how to accomplish that.

I created a plugin, let's say it's called MyPlugin.

In this plugin I created a controlled called WhateverController which has a Show action (i.e. a showAction method).

Without doing anything else, that automatically gives me an url http://mydomain.com/my-plugin/whatever/show which runs the abovementioned action.

However:

1. The url http://mydomain.com/my-plugin/whatever/show/123 does not automagically populate an id parameter with the value 123, as it happens with the application's builtin controllers.
That is, if in WhateverController::showAction() I try to run:

    $id = $this->getRequest()->getParam('id');

that does not work. It returns null or an otherwise empty value.

So, I searched the documentation but found nothing about routes and how to customize them.
I also looked at the source code but it's too complex.

So, the first basic thing that the documentation fails to address is:

  • How do you configure your plugin's routes so that they have the same basic default behavior of Omeka's builtin routes, where the pattern :controller/:action/:id gives you a request parameter called id.

Or called something else, which is another thing I wanted to do.

(I'm not sure whether this is something that can be entirely addressed at the plugin level or if I need to edit the application configuration to accomplish this; if it's the latter then there's a big flaw in the plugin architecture but for now I could live with that as long as somebody tells me how to do that. Either way it should be in the docs)

Much of this stuff works seems to be handled by the Zend Framework, which is also poorly documented, at least this version (not nearly as poorly as Omeka, of course), but it doesn't help that Omeka's documentation says absolutely nothing of which features of Zend exactly it is using and how.

2.
I would like some of the plugin controllers, whose names I know don't clash with any builtin controller, to be accessed without the plugin name as a prefix

That is, I would like to have this url:

http://mydomain.com/whatever/show

instead of http://mydomain.com/my-plugin/whatever/show, to be mapped to my plugin's WhateverController::showAction()

There must be a way to do that. It can't be that I'm condemned to have all the urls that are handled by my plugin's controllers start with the plugin name.

Again, this is probably handled by Zend and it may be documented in Zend's documentation, but Omeka's documentation gives me no clue where to look or even what to look for.

I know I can address both with Apache rewrite rules in .htaccess, but there must be a cleaner way.

@zerocrates
Copy link
Member

You're going to want to use the define_routes hook. Routing is handled by Zend's router component.

This is a pretty solid issue except that you just can't seem to resist getting your little digs in even though I've asked you repeatedly not to do that. So, I'm going to go ahead and block you from interacting with the Omeka organization's issue trackers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants