set() is a method of the controller, not the component. Try $this-
>component->set(...)
On Oct 10, 7:02 pm, worldcommander <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I'm working on converting an existing site to CakePHP. The site is
> similar to a blog where each post can have many related articles (each
> in it's own MySQL table). The posts are organizaed geographically,
> meaning the end user can see national posts, state posts, region post,
> etc.
>
> My desire is to display a list of posts for each levels/area and a
> list of related articles that correspond to that level (ie all related
> articles for California when viewing all posts for California).
> Because there is a lot of reuse of the same code I'm assuming a
> component will work best.
>
> My problem is that when I try to use $this->set('article_block',
> $this->Article->findAll()) in my component I get an error that says "Call to
>
> undefined function: set()" and the reference is to the line in my
> component file. I can't figure out why I can;t access the set()
> method.
>
> Below is s a stripped down version of how my component is set up and
> how the controller is accessing the component (note - at this point
> I'm just trying to to get the component to work so I haven't even
> looked at the view part)
>
> Any help is greatly appreciated!
>
> Component - File name: articlelist.php
> --------------------------------------------------------------
> class ArticlelistComponent extends Object
> {
> var $controller = true;
>
> function startup(&$controller)
> {
> $this->controller =& $controller;
> }
>
> function init($cond)
> {
> $this->_index($cond);
> }
>
> function _index($cond)
> {
> $this->set('article_block', $this->Article->findAll($cond));
> }
>
> }
>
> Controller - File name posts_controller.php
> --------------------------------------------------------------
>
> class PostsController extends AppController
> {
> var $name = 'Posts';
> var $components = array(''Articlelist');
>
> function index()
> {
> $this->Articlelist->init($cond);
> }
>
> }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---