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

Error when Cakes admin routing #13

Open
majic3 opened this issue Nov 11, 2009 · 3 comments
Open

Error when Cakes admin routing #13

majic3 opened this issue Nov 11, 2009 · 3 comments

Comments

@majic3
Copy link
Contributor

majic3 commented Nov 11, 2009

When changing admin prefix in config/core.php admin does not user the admin prefixed actions & view
http://forums.wf.klevo.sk/comments.php?DiscussionID=147&page=1#Item_0

@majic3
Copy link
Contributor Author

majic3 commented Jan 6, 2010

So when admin route is changed the prefix param is not set

and the action loses the admin_ part eg admin_index becomes index

I can fix it to make admin work but at the expense of everything else (nothing else is displayed - content encoding error)

I was working on the assumption that I could set these missing items in the params array but this causes issues

@majic3
Copy link
Contributor Author

majic3 commented Jan 6, 2010

(isset($this->params['prefix']) && $this->params['prefix'] == 'admin') or isset($this->params['admin']);

So digging around and testing old code I can log in and view dashboard - but nav links are borked - and items links though correct are not finding admin_* views due to rename of admin routing

@majic3
Copy link
Contributor Author

majic3 commented Jan 8, 2010

partial success with the following (dashboard loads) -- it was possible to get admin working but it would load the default layout inplace of admin_layout (but I can seem to recall what I had to enable this)

in routes

if($prefix !== 'admin') {
$wfControllers = array('pages', 'posts', 'users', 'categories', 'comments', 'assets', 'messages', 'uploads', 'settings');
foreach ($wfControllers as $shortcut) {
    Router::connect(
        "/$prefix/$shortcut", 
        array('controller' => "$shortcut", 'action' => 'index', 'prefix' => 'admin')
    );

    Router::connect(
        "/$prefix/$shortcut/:action/*", 
        array('controller' => "$shortcut", 'prefix' => 'admin')
    );
}
Router::connect("/$prefix/assets/jlm", array('controller' => 'assets', 'action' => 'jlm', 'prefix' => 'admin', 'admin' => true));}

in app_controller

code

function isAdminAction() {
    if (isset($this->params[Configure::read('Routing.admin')]) and $this->params[Configure::read('Routing.admin')]) {
        return true;
    }   elseif($this->params['admin'] and (Configure::read('Routing.admin') !== 'admin'))   {
        return true;
    }
    return false;
}

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

1 participant