Plugin Admin Dashboard 404 View Error

Looking at similar issues to this older post - Add entry admin dashboard
Omeka 3.0

I have the following in class PDFtotextNgramBridgePlugin extends Omeka_Plugin_AbstractPlugin :

public function hookDefineAcl($args)
    {
        $args['acl']->addResource('PDFtotextNgramBridge_Index');
    }

    /**
    * Add the Derivative Images navigation link.
    */
    public function filterAdminNavigationMain($nav)
    {
        $nav[] = array('label' => __('PDFtext to Ngram Bridge'), 
                       'uri' => url('PDFtotextNgramBridge'), 
                       'resource' => 'PDFtotextNgramBridge_Index',
                       'privilege' => 'index');
        return $nav;
    }

define_acl is in $_hooks.

In views/admin/index I have index.php with my php page - has a form.

in controllers/IndexController.php I have

class PDFtotextNgramBridge_IndexController extends Omeka_Controller_AbstractActionController
{
    public function init()
    {
        // Set the model class so this controller can perform some functions, 
        // such as $this->findById()
        //$this->_helper->db->setDefaultModelName('PDFtotextNgramBridgePage');
    }

    public function indexAction()
    {
        if ($this->getRequest()->isPost()) {
            $options = array('pdftotextngrambridge_run' => $this->getParam('pdftotextngrambridge_run'), 
                             'pdftotextngrambridge_replace' => $this->getParam('pdftotextngrambridge_replace'));
            Zend_Registry::get('bootstrap')->getResource('jobs')
                ->sendLongRunning('PDFtotextNgramBridgeJob', $options);
            $this->_helper->flashMessenger(__('Processing files. This may take a while. You may continue administering your site.'), 'success');
        }
        
        /*$db = $this->_helper->db->getDb();
        $sql = "SELECT mime_type FROM $db->File GROUP BY mime_type";
        $this->view->mime_types = $db->fetchCol($sql);*/
    }
}

This will all be edited. At this point I’m just trying to get the admin page on the dashboard to show up. It’s stuck at a 404… which to me points to view / resource issues. But can’t find the problem

There could be several things going on here, for example you’ll get a 404 ultimately if you don’t have a view for this action, though it looks like you’ve done that.

But the main issue would probably be that you’re not accounting for how Zend transforms module, controller, and action names from CamelCase to hyphenated for URLs. The default URL for a module like “PDFtotextNgramBridge” is going to be something like “pdf-totext-ngram-bridge” (I’d have to refresh myself on exactly how all-uppercase words are handled to be sure).

1 Like

That was it - camelcase to dash with multiple capitals.

changed PDFtotextNgramBridge to PdftotextNgramBridge and in the URI used the following

        $nav[] = array('label' => __('PDFtext to Ngram Bridge'), 
                       'uri' => url('pdftotext-ngram-bridge'), 
                       'resource' => 'PdftotextNgramBridge_Index',
                       'privilege' => 'index');

solved the issue.

perhaps have a note in the documentation for resources / uris that this is the default?

We can make a note of it, yeah. We’ve typically deferred to the Zend Framework documentation on some of that stuff, but of course that’s old legacy docs for them now.

Were you looking at a particular documentation page where you were expecting to see that information?

This topic was automatically closed 360 days after the last reply. New replies are no longer allowed.