Closed larry-tx closed 13 years ago
LarryTX,
few things on your code: if you run that sql in your mysql console (or phpMyAdmin) you will answer your self why the fields are not shown :)
SELECT
cakemenu.id,
cakemenu.name
FROM
`cakemenu` AS `Menu`
WHERE
1 = 1
ORDER BY
`Menu`.`lft` ASC
As you can see the cakemenu table, has been aliased with Menu alias. So, instead of cakemenu.id you should write Menu.id (same apply for name column).
Another thing is the second parameter of Cakemenu::nodes(); - it should be a reference to Authake component, rather than a string.
Also, remove the field's option from the first parameter, because the plugin require some of the fields mostly cakemenu.link :) but also the icon. So without them it will throw some warnings.
So, your final code should look like this:
function beforeFilter() {
$this->set('menu', $this->Cakemenu->nodes(null, $this->Authake, null));
$this->auth();
}
I've got Cakemenu and Authake, each, working perfectly. They are two fantastic plugins. Unfortunately, try as I might, I can't get them to work together. I get the error message that the relevant columns in my cakemenu table don't exist when in fact, they do.
The SQL for my cakemenu table is:
CREATE TABLE
cakemenu
(id
int(11) NOT NULL AUTO_INCREMENT,name
varchar(45) DEFAULT NULL,link
varchar(255) DEFAULT NULL,parent_id
varchar(45) DEFAULT NULL,lft
int(11) DEFAULT NULL,rght
int(11) DEFAULT NULL,icon
varchar(45) DEFAULT NULL, PRIMARY KEY (id
) ) ENGINE=InnoDB AUTO_INCREMENT=49 DEFAULT CHARSET=utf8;The beforeFilter in app_controller is:
And error message that I'm getting is:
Warning (512): SQL Error: 1054: Unknown column 'cakemenu.id' in 'field list' [CORE\cake\libs\model\datasources\dbo_source.php, line 681] Code | Context
$sql = "SELECT cakemenu.id, cakemenu.name FROM
cakemenu
ASMenu
WHERE 1 = 1 ORDER BYMenu
.lft
ASC " $error = "1054: Unknown column 'cakemenu.id' in 'field list'" $out = nullDebugger::handleError() - CORE\cake\libs\debugger.php, line 306 DboSource::showQuery() - CORE\cake\libs\model\datasources\dbo_source.php, line 681 DboSource::execute() - CORE\cake\libs\model\datasources\dbo_source.php, line 266 DboSource::fetchAll() - CORE\cake\libs\model\datasources\dbo_source.php, line 410 DboSource::read() - CORE\cake\libs\model\datasources\dbo_source.php, line 820 Model::find() - CORE\cake\libs\model\model.php, line 2111 CakemenuComponent::_fetch() - APP\plugins\cakemenu\controllers\components\cakemenu.php, line 104 CakemenuComponent::nodes() - APP\plugins\cakemenu\controllers\components\cakemenu.php, line 39 AppController::beforeFilter() - APP\controllers\app_controller.php, line 8 Controller::startupProcess() - CORE\cake\libs\controller\controller.php, line 526 Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 187 Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 171 [main] - APP\webroot\index.php, line 83
Query: SELECT cakemenu.id, cakemenu.name FROM
cakemenu
ASMenu
WHERE 1 = 1 ORDER BYMenu
.lft
ASCWarning (2): Invalid argument supplied for foreach() [CORE\cake\libs\model\model.php, line 2318]
Fatal error: Call to a member function getUserId() on a non-object in E:\xampp\htdocs\mysite\app\plugins\cakemenu\controllers\components\cakemenu.php on line 117
Can you give me any idea what I'm doing wrong?