Solution:
After these changes are made, it works.
1)
public $components = array('Comments.Comments' =>
array('userModelClass' => 'User'));
//This is used because in my case, I'm using my direct Users table,
not a plugin Users.
2)
$this->Comments->actionNames = array('view');
//It is added in beforeFilter of controller to enhance actions
performance
3)
public function callback_commentsInitType() {
return 'flat';
}
//This is used to replace
$this->passedArgs['comment_view_type'] = 'flat'; //which was in
beforeFilter (Controller)
//It does the same thing except by using function maybe it is better.
Jose maybe you may want to comment on this better.
4)
public $displayField = 'username';
//This is placed in the User model. Well, to display the username
along with the comments.
The end.
Thanks for CakeDC Jose_zap who has helped me by troubleshooting and
guiding. Great and awesome.
Regards,
Maxim
On Jan 4, 11:59 pm, John Maxim <[email protected]> wrote:
> Ok Jose, thanks for offering help.
>
> On Jan 4, 11:47 pm, José Lorenzo <[email protected]> wrote:
>
> > Hi Jhon,
> > It looks like you have not configured properly the component or
> > behavior.
>
> > Could you please join the #cakedc irc channel in order to get help
> > with this plugin? We will be waiting for you to offer any help you
> > need.
>
> > Cheers.
>
> > On Jan 4, 11:32 am, John Maxim <[email protected]> wrote:
>
> > > Hi the below is exactly what is loaded after placing the debug code,
> > > Jeremy. btw, Gavin is a neighbour's 1 yr old baby.
> > > ~~~
> > > Post
>
> > > Id
> > > 4
> > > User
> > > 6
> > > Title
> > > Gavin is mean
> > > Body
> > > I like him .. cutie
> > > Created
> > > 2011-01-04 08:13:45
> > > Modified
> > > 2011-01-04 08:13:45
>
> > > Actions
>
> > > * Edit Post
> > > * Delete Post
> > > * List Posts
> > > * New Post
> > > * List Users
> > > * New User
>
> > > Add comment
> > > << Most Recent | Oldest >>
> > > app\plugins\comments\views\elements\comments\flat\item.ctp (line 28)
>
> > > Array
> > > (
> > > [Comment] => Array
> > > (
> > > [id] => 4d22e4a2-be74-499a-b110-0c2cca884e0a
> > > [parent_id] => 0
> > > [foreign_key] => 4
> > > [user_id] => 7
> > > [lft] => 1
> > > [rght] => 8
> > > [model] => Post
> > > [approved] => 1
> > > [is_spam] => clean
> > > [title] => Naughtier..
> > > [slug] => naughtier
> > > [body] => day by day he's naughtier ... uncontrolled
>
> > > :)
> > > [author_name] =>
> > > [author_url] =>
> > > [author_email] =>
> > > [language] => en-us
> > > [comment_type] => comment
> > > [created] => 2011-01-04 09:13:06
> > > [modified] => 2011-01-04 09:13:06
> > > )
>
> > > [Post] => Array
> > > (
> > > [id] => 4
> > > )
>
> > > [UserModel] => Array
> > > (
> > > [id] => 7
> > > [slug] =>
> > > )
>
> > > )
>
> > > app\plugins\comments\views\elements\comments\flat\item.ctp (line 29)
>
> > > UserModel
>
> > > On Jan 4, 11:23 pm, Jeremy Burns | Class Outfit
>
> > > <[email protected]> wrote:
> > > > Just before line 29 (where the error is firing) type:
>
> > > > debug($comment);
> > > > die(debug($userModel));
>
> > > > This will print out the contents of the $comment variable and also the
> > > > name of the model being used for users. It is possible that $comment is
> > > > empty, in which case there would be no array node where the user should
> > > > be, and therefore the error fires.
>
> > > > Jeremy Burns
> > > > Class Outfit
>
> > > > [email protected]http://www.classoutfit.com
>
> > > > On 4 Jan 2011, at 15:20, John Maxim wrote:
>
> > > > > Hi Jeremy,
>
> > > > > I don't know how to debug $comment, actually I am able to post new
> > > > > comment from the posts/ page, no error or whatsoever.
>
> > > > > After the comment is added and when I view the comment in view.ctp
> > > > > here comes the error above the comment which was posted justnow. The
> > > > > rest of the page is just loaded like usual.
>
> > > > > Can you tell me how to debug my $comment ?
>
> > > > > The userModel is basically this line I added according to the
> > > > > instruction cakedc comments plugin page:
>
> > > > > public $components = array('Comments.Comments' =>
> > > > > array('userModelClass' => 'Users.User'));
>
> > > > > it is to be placed in any of the controller which you want comment
> > > > > working, I chose Posts controller so it goes in my posts controller.
>
> > > > > It follows by $this->passedArgs['comment_view_type'] = 'flat';
>
> > > > > in beforeFilter function..
>
> > > > > But I don't know what us $userModel, Jeremy maybe you could point out
> > > > > the missing part I have in this code ?
>
> > > > > Thanks..
>
> > > > > On Jan 4, 11:08 pm, Jeremy Burns | Class Outfit
> > > > > <[email protected]> wrote:
> > > > >> What happens when you debug out $comment? And what is $userModel?
>
> > > > >> Jeremy Burns
> > > > >> Class Outfit
>
> > > > >> [email protected]http://www.classoutfit.com
>
> > > > >> On 4 Jan 2011, at 15:06, John Maxim wrote:
>
> > > > >>> Line 29:
>
> > > > >>> Line 29 is $_userLink = $comment[$userModel]['username'];
>
> > > > >>> the above is the line of code from the error message posted earlier.
>
> > > > >>> On Jan 4, 10:20 pm, John Maxim <[email protected]> wrote:
> > > > >>>> There is a username column in users table.
>
> > > > >>>> The support from the cakedc tickets are almost all left
> > > > >>>> unanswered..
>
> > > > >>>> I am losing hope with this plugin.
>
> > > > >>>> not one response about this in irc..
>
> > > > >>>> strangely something is wrong with user's ID or name; found a link
> > > > >>>> here:http://www.jonathansibley.com/cakephp/comments-plugin-by-cakedc-getti...
>
> > > > >>>> but doesn't help even after adding public $displayField =
> > > > >>>> 'username';
>
> > > > >>>> in users controller..
>
> > > > >>>> I suspect there is displayField function missing ?
>
> > > > >>>> On Jan 4, 9:49 pm, Joshua Muheim <[email protected]> wrote:
>
> > > > >>>>> I don't know this plugin, but this sounds to me like your database
> > > > >>>>> tables does not have a username column...?
>
> > > > >>>>> On Tue, Jan 4, 2011 at 2:20 PM, John Maxim <[email protected]>
> > > > >>>>> wrote:
> > > > >>>>>> Hi people,
>
> > > > >>>>>> I installed this :
>
> > > > >>>>>>https://github.com/CakeDC/comments
>
> > > > >>>>>> I am having problem with:
> > > > >>>>>> Notice (8): Undefined index: username [APP\plugins\comments\views
> > > > >>>>>> \elements\comments\flat\item.ctp, line 29]
>
> > > > >>>>>> when load my view page..
>
> > > > >>>>>> regards,
> > > > >>>>>> Maxim
>
> > > > >>>>>> Check out the new CakePHP Questions
> > > > >>>>>> sitehttp://cakeqs.organdhelpotherswiththeirCakePHPrelated
> > > > >>>>>> questions.
>
> > > > >>>>>> 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 athttp://groups.google.com/group/cake-php?hl=en
>
> > > > >>> Check out the new CakePHP Questions
> > > > >>> sitehttp://cakeqs.organdhelpotherswiththeir CakePHP related
> > > > >>> questions.
>
> > > > >>> 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 athttp://groups.google.com/group/cake-php?hl=en
>
> > > > > Check out the new CakePHP Questions
> > > > > sitehttp://cakeqs.organdhelpotherswith their CakePHP related
> > > > > questions.
>
> > > > > 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 athttp://groups.google.com/group/cake-php?hl=en
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
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