Hello,
I am currently attempting to put together a home.ctp for the
application I'm working with. On this page I am attempting to render
a couple of different views I've got put together. The one I am
having an issue with is rendering the side navigation menu. The
following is my code for the file doing all the renders (home.ctp):
<div class="page">
<div class="menu"><?php echo $this->render('../menus/viewAll',
'ajax');?></div>
<div class="pic"><?php echo $html->image('boise.jpg',
array('alt'=>'Boise', 'width'=>'200', 'height'=>'200'));?></div>
<div class="message"><?php echo $this->render('../contents/
view_all.ctp', 'ajax');?></div>
</div>
When I load this page in a browser all the content comes up correctly
as long as I am using the standard html->link() technique. What I
would like to do is implement ajax links so anything a user clicks on
the menu is going to load into the "message" div tag without a page
reload. The problem I have run into is that when I just go to the
view (navigating to localhost/menus/viewAll) the ajax all works
perfectly, but when I access it via (localhost/) through home.ctp the
ajax helper is suddenly no longer active and I get the standard un-
declared helper variable error: "Undefined variable: ajax...."
I'll also include some of the controller:
<?php
class MenusController extends AppController
{
var $name = 'Menus';
var $helpers = array('Ajax', 'Javascript');
function index()
{
$this->set('menus', $this->Menu->findAll());
}
function viewAll()
{
$menus = $this->paginate();
if(isset($this->params['requested'])) {
return $menus;
}
$this->set('menus', $menus);
}
?>
Also a side note, I have included the helpers declaration in the main
app_controller.php as well in an attempt to force the helper to load.
And finally, the view_all.ctp which does not render correctly
utilizing the ajax helper:
<?php
$menus = $this->requestAction('/menus/viewAll/sort:id/
direction:asc');
$helpers = array('Ajax', 'Javascript');
foreach($menus as $menu):
echo $html->tableCells(array($ajax->link($menu['Menu']['text'],
$menu['Menu']['link'], 'message')));
echo '<br />';
endforeach;
?>
I figure that I'm either a very small error in one place or
approaching it completely wrong, any help is much appreciated.
Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---