Some advice on creating the plugin with comments, please
Hi,
I need some advice on creating the plugin to have some special messages. A kind of thanks messages with description.
I want create new column on vanilla comment table for differentiate some special messages. (I do not know if it's a good idea to add new column on this table.)
And I want to put a link below the image of member on messages.
On click in link navigate to bottom of discussion (or may be show popup form) to write new message and save the message on the table comment with a flag (number 1) on new column.
I'll have to create a hidden field with value 1 to insert for example.
I don't know how to save on the new column (value 1) with the user message.
There must be only one user message to another user in the discussion.
Then I want to show these comments on the user wall.
Someone can tell me how best to do it? I will appreciate any kind of advice.
Thanks.
Comments
That sounds like a shortcut for writing wall posts. How would they be connected? Would you like to see some kind of "introductional sentence" before such wall posts together with a link to the comment? And in the discussion, how should it be made visible (if it should be at all) that someone has made a wall post based on that comment. What is the reason for limiting it to one connected wall post only?
Hi @R_J
Yes it would be nice have some kind "introduction sentence" to explain.
I want to make some kind of "evaluate and give thanks to member" other members based on that member actions on this discusion, not based in simplest messages and reactions.
That is the reason to have only one evaluate user to another user message by discussion.
I have created discussions where each member can offer to others the promotion code. When someone use it promotion code could evaluate user and his help. This evaluate will help others members to have some global view about confidence on this member. Then can be engaged with Yaga for badges.
I thought before use user activity wall for that but I like to have these messages also in the comments of the discussion which can be found easier. Apart the profile folder I have forbidden to index on my robots.txt
If I go to save as message then I can recover it with my flag (new column) in comment table to show on the user profile.
It will come down to some kind of "reaction text", correct?
If you want to show that text as a wall post, I would save it as a wall post (table Activity). Saving it also in another table is a bad idea.
An additional column in the Comment table is most useful, if the column is needed for nearly all comments. If there will be more than one reaction text for one comment (even if they are from different users), you shouldn't do this by adding a column to Comment, but by storing them somewhere else.
I guess you like your users to be able to react to the discussion (the first post in a thread) also. Then you will have to duplicate what you do for tables Comment and Discussion.
But no matter where it is saved, you will be able to show it wherever you like. So if you save it in table Activity, you would be able to show it in the comments.
You've asked for help, but may I ask if you have started anything by now? Please don't take it as an offense, I just want to know what kind of help you need.
Yes I have started modifiying how to profile page plugin.
http://vanillaforums.org/addon/howtoprofilepage-plugin
I'll use this page to list the messages. I have placed editor textarea that appears only for others user and description. For the same user can not comment himself. But I stopped because I have not everything very clear.
This comment is more focused on user action evaluation and not your comment (or the first post in a thread). I want to show these comments unmixed with comments activity. Or at least on the special link when enter on user activity to show only evaluation messages with option to show all activity.
In what kinds of comments I will be able to show? On discusion comments o activity comments?
I understand that I can do this with the activity table but I wanted also to be displayed evaluation messages in the comments of the discussion. So I focused on Comment table and maybe I'm wrong.
I misunderstood you and that's why I was suggesting using the Activity table. If you create some kind of reaction texts which are some sort of data that is no where else stored, you should create a new table.
Create the table in a
public function structure()
which you call inpublic function setup()
. Do a full text search in the plugins on your server. You will find many examples.I would use columns ID, RegardingUserID, InsertUserID, ForeignType, ForeignID, Body
If you like to show all reaction texts for a special user, you could do it like that:
Gdn::sql()->getWhere('YourTable', array('RegardingUserID' => $profileUserID));
And if you like to show all reaction texts that exist for a given comment, you would be able to get them with
Gdn::sql()->getWhere('YourTable', array('ForeignType' => 'Comment', 'ForeignID' => $commentID));
But I would add a column to Comment/Discussion like "CountReactionTexts" or "HasReactionText" so that you only execute the above sql when there will be a result.
When I said "if you save it in table Activity, you would be able to show it in the comments" I better should have said "when you store it anywhere in the database, you'll be able to access it anywhere". You only have to store the correct references along with the text.
Thank you very much for your advice and examples of how to use model. I will serve.
I found this wiki page about vanilla - http://vanillawiki.homebrewforums.net/index.php/Main_Page
and saw there many code examples similars as you advise.
It's a good idea to create a new table, but I still thinking add evaluation comment in the comment table.
The reasons are:
I will add RegardingUserID into comment table.
Having RegardingUserID column I will know what user has been regarding. And can do select messages by RegardingUserID on his profile.
Also I can limit insert commnets by InsertUserID, DiscussionID and RegardingUserID and time
What do you think about?
Or maybe you see create a new table and link to comment with ID?
I have created Evaluate link next to the name using (DiscussionController_AuthorInfo_Handler). I need one thing, when you click on the link I would like to open a popup form like the Flagging plugin and save form like simple comment with a new RegardingUserID column.
I don't resolve to create a popup form yet. I have only the frame without form
Then I will need to save content as the message on comment table. I guess I need to have hidden fields with values too.
I have finally seen the popup form.
Now I need to save content as the message on comment table. I guess I need to have hidden fields with values too.
Try it like that
I think you need a new table. You will have multiple texts for one comment and an additional column is the wrong solution for this.
Remember: you could display the text the same way as you display the link. All you have to do is to choose the hook you need.
...
I've already got form popup based on Flaggin plugin
And how I will show evaluated comment between discusion comments if I will keep it in new table?
If you like to display each text below the comment, do it like that:
You do not need to have the text stored in the Comment table, as long as you store the texts together with the CommentID in your new table.
By now I only handled comments. If you allow people to react on discussions also, you might have to change some things...
But on this way it will check for every comment on new table extra information. I'm wrong?
If that is so it is performance penalty.
And comment reaction can be created one against 50 messages for example.
This would be good adding sql join with a new table when the discussion comments are queried.
I only outlined the basics. Like I said in a former posing, I would add a column "HasReactionText" which you can set to true or false. And then you could start
This will stop your plugin from performing a database call on every comment and it would be better than joining another table.
If there could be 50+ texts per comment, there is no easy way to store it in only one column. And no clean way, which is more important.
By the way: this plugin sounds really promising!
...
I like your solution on that way !
You gave me the infrormacion to think and act ...
Many thanks
Finally I have it clear.
I'll save the evaluation comment in the comment table with extra information on the new table. It is a user rating (evaluation) and is a comment like the others and it does not belong to any particular comment.
Comment table will have only new column "HasExtraInfo"
I'll show extra information with the comment and give the styles on lists.
I have a question. How it is easier to implement?
1 - Save new comment with extra information from the popup window? I suppose that I need to use CommentModel to save a new comment. Then redirect to show this last comment on discussion (#latest)
2 - On click pull towards the end of comments and use existing textbox, show extra information to choose and save the comment with this extra information?
For show extra information I can use DiscussionController_BeforeCommentForm_Handler
But how I can intercept this extra information on insert the comment later?
I got it with CommentModel save on implement number 1