Sunday, July 5, 2009

Re: Problems w/ Commentia Behavior

It's attached to quick a few models (Blog, Skatepark, Event, etc). I'm
calling the save from within my comments_controller add() method
though. I have it set up a little unusual. In my routes I have:

Router::connect("/:m/:slug/comment/",array
("controller"=>"comments","action"=>"add"),array("pass"=>array
("m","slug")));

and then in my comments_controller.php I have:

function add($m, $slug) {

if($this->RequestHandler->isPost() && !empty($this->data)) {

$result = (... get the related event, blog post's id by using the
$m model and find using the $slug...)

$this->data['Comment']['text'] = $this->__sanitizeText($this->data
['Comment']['text']);
$this->data['Comment']['model'] = $m;
$this->data['Comment']['association_key'] = $result[$m][id'];

if($this->Comment->save($this->data)) {

}

// $this->redirect($this->referer());

}

else {

$this->render();

}

$this->set("comments",$this->Comment->find("all",array
("conditions"=>array())));

}

On Jul 5, 4:28 pm, Miles J <mileswjohn...@gmail.com> wrote:
> Ok but what model are comments attached to? Entry?
>
> On Jul 5, 8:06 am, Kyle Decot <kdec...@gmail.com> wrote:
>
>
>
> > Certainly. My tables is just called comments. Here is my Comment
> > Model:
>
> > <?php
>
> > class Comment extends AppModel {
>
> >         var $name = 'Comment';
> >         var $actsAs = array('Commentia');
>
> > }
>
> > ?>
>
> > My table structure looks almost identical to the one on your blog but
> > I did add some extra fields (IP address, model).
>
> > On Jul 5, 5:34 am, Miles J <mileswjohn...@gmail.com> wrote:
>
> > > May I see your $actsAs?
>
> > > And what are the names of your comments table and the model you are
> > > attaching this to.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: