You should be separating the index action, and the requested action.
try creating
function getPhotos()
{
return $this->Photo->findAll();
}
and calling that from your element.
----- Original Message ----
From: Kyle Decot <[EMAIL PROTECTED]>
To: CakePHP <[email protected]>
Sent: Tuesday, May 13, 2008 1:51:52 PM
Subject: Reusable Elements
I am attempting to create some reusable elements using the tutorial
at:
http://bakery.cakephp.org/articles/view/creating-reusable-elements-with-requestaction
and am running into some problems.
Here is my controller:
function index() {
$recent = $this->Photo->findAll();
if(isset($this->params['requested'])) {
return $recent;
}
$this->set("recent",$recent);
$this->set("title","Skatepark Photos");
}
and my element:
<?php
$recent = $this->requestAction('photos/index');
if(!empty($recent)):
print_r($recent);
else:
echo "it's not working...ugghh";
endif;
?><h2>Recent Photos</h2>
It always says that $recent is empty. Anyone know what's causing this?
Could it be the $this->params['requested']?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---