Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

New Plugin

Good afternoon everyone. I am working on a plugin. Here is how it functions:

  • Creates a discussion button that states, "New Review".
  • Automatically adds, "Review: " to the beginning of the discussion title.
  • Has a fillable form for review contents.
  • Create a database entry exactly like comments that counts how many "Reviews" a user has made

Those are the four functions I would like out of the gate. I can post my code tonight for those that would like to help. I'm using the Q&A plugin as a reference but the lack of code comments is leading me to road-blocks.

Functionality that I wish to have in the future for this plug-in or separate plugins:

  • Auto-fill sections of the form based on previous entries.
  • Display a link next to the users profile in each discussion/comment detailing the number of reviews they've submitted which leads to a page that lists all of their reviews, much like comments.

What I am asking for right now, is any suggestions on how to approach this before I post by code.

Thanks.

«13

Comments

  • rbrahmsonrbrahmson "You may say I'm a dreamer / But I'm not the only one" NY ✭✭✭

    Again, pointers from my cell phone while I'm away: (1) you are probably creating a new discussion type (QnA does) (2) Not sure QnA is a good basis. A combo of the example and Howto plugins will be just as good and possibly simpler (there is one that shows how to do forms). Good luck!

  • R_JR_J Ex-Fanboy Munich Admin
    edited May 2016

    You have to decide if you re-use discussion/comment system from Vanilla or if you bake a complete new content type. Scan through shadowdares discussions: he created the article addon and was facing the same question. He decided to re-use discussion/comments and he is an experienced Vanilla developer.
    I would strongly advise to reuse what Vanilla offers as much as you can!

    qna plugin is very sophisticated and simply copying it would be very hard when this is your first experience with Vanilla. But basically it has all you need to get started. I would just recommend to write the plugin on your own and only look at the source to get a help how some problems can be solved
    I've walked a few starters through creating simple plugins. This one wouldn't be simple, but if I would walk someone through it step by step, I guess I would give him this tasks.

    1. create a plugin that adds a dropdown option to the new discussion button. See the qna plugin and take a look at everything that has todo with "DiscussionType".
    2. let a click on your newly created "new review" button open a page that looks exactly like a new discussion page. Look at qna plugin, mostly on the PostController methods
    3. create a structure() method which adds a "IsReview" column to the Discussion table. Search plugin folder for "structure" and you'll find some examples
    4. add a hidden field named IsReview to the form from 2. which flags newly created content as review (search for addhidden)
    5. add more columns to Discussion and fields with the same name to the form. Try to find out with qna again.

    That would take a while...

  • @R_J said:
    You have to decide if you re-use discussion/comment system from Vanilla or if you bake a complete new content type. Scan through shadowdares discussions: he created the article addon and was facing the same question. He decided to re-use discussion/comments and he is an experienced Vanilla developer.
    I would strongly advise to reuse what Vanilla offers as much as you can!

    qna plugin is very sophisticated and simply copying it would be very hard when this is your first experience with Vanilla. But basically it has all you need to get started. I would just recommend to write the plugin on your own and only look at the source to get a help how some problems can be solved
    I've walked a few starters through creating simple plugins. This one wouldn't be simple, but if I would walk someone through it step by step, I guess I would give him this tasks.

    1. create a plugin that adds a dropdown option to the new discussion button. See the qna plugin and take a look at everything that has todo with "DiscussionType".
    2. let a click on your newly created "new review" button open a page that looks exactly like a new discussion page. Look at qna plugin, mostly on the PostController methods
    3. create a structure() method which adds a "IsReview" column to the Discussion table. Search plugin folder for "structure" and you'll find some examples
    4. add a hidden field named IsReview to the form from 2. which flags newly created content as review (search for addhidden)
    5. add more columns to Discussion and fields with the same name to the form. Try to find out with qna again.

    That would take a while...

    I'll go ahead and use the discussion/comment system for Vanilla with the exception of adding a form for my "New Review" discussion thread.

    1. Done.
    2. Done.
    3. Done.
    4. Still researching how to do this.
    5. I'm not sure I understand this assignment.

    Would you like to see my current code?

  • R_JR_J Ex-Fanboy Munich Admin

    @Rangerine said:
    4. Still researching how to do this.

    Maybe that had been a bad advise. Try to add "some" field to the form...

    @Rangerine said:
    Would you like to see my current code?

    For sure. You can either create a GitHub or bitbucket repo or simply post it here.

  • Alright. Here is what I have:

    • class.newreview.plugin.php

    I also have three folders with their contents listed underneath:

    locale
    -en.php //no idea what this is, copied from QnA and left blank.
    modules
    -class.newreviewmodule.php //renders the "New Review" button
    views
    -commentoptions.php //uses default vanilla comments options
    -discussionoptions.php //uses default vanilla discussion options
    -newreviewpost.php // not sure what this does, copied from QnA plugin
    -post.php //modified default vanilla post options to fit new review wording (change button names, etc.)

    I'll get GitHub set-up for myself to make this easier next time. Link to my GitHub:

    https://github.com/Rangerine/NewReviewPlugin

  • R_JR_J Ex-Fanboy Munich Admin

    @Rangerine said:
    Alright. Here is what I have:

    • class.newreview.plugin.php

    You know that there's no code to see here? Also the repo is just a cloned QnA plugin. I think you would learn better if you write the plugin from ground on up instead of modifying the QnA plugin.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    @R_J said:
    is just a cloned QnA plugin.

    It looks like he cloned the QnA and tried to just change the names but failed to do it on all the files..

    I think this would be easier if they simple changed via definitions, Question to Review… the problem then would be what to call the answers… or when someone has accepted the answer.. what is the point … ?

    @Rangerine Best make a plugin from scratch is right… and if you are going to use code written by someone else to create your plugin, you must include credits to the original author at the very least.

  • I uploaded the wrong folder. I did use the QnA plugin as a template. The credit is given in the beginning of the file.

    Please take a look again. What I did was remove all of the extras that the QnA plugin has such as the badges, answers management, etc. and just left the sections I was concerned with (creating a new thread titled 'New Review').

  • @R_J I've commented the Plugin throughout to show what I know and don't know. I'm not ready to write one from scratch, this is turning out to be a very good introduction for when I write my first plugin from scratch.

    @vrijvlinder I don't need the answers portion. I only need a button that starts a new thread as a new review.

    The plugin is working and am now working to implement the following to it:

    • Title all threads started with plugin as, "New Review: "
    • Have a generic form for the user to fill out the basic elements of a review.

    The plugin I will write from scratch will do the following:

    • Take the reviews written by a user and display it on their profile and next to their name on comments.
    • The review count in the profile and comments will be a link taking any sure to all the reviews written by that person.
    • Every review will grant the user premium access for 30 days after their review has been approved my a moderator.
  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited May 2016

    I'm not ready to write one from scratch

    Then why the fck did you publish it as your own ???

    @vrijvlinder I don't need the answers portion. I only need a button that starts a new thread as a new review.

    Indeed, so all you would have to do is change the definitions. Change the words question, with reviews…. Not clone an existing plugin and call it your own…

    You would publish a plugin based on QnA that instead of the word question, it would be Review, and answers would be accepted reviews.

  • @vrijvlinder I haven't published it. If I do I wont say I made it. I'll credit the original publisher.

    I wouldn't just have to change the definitions.Accepted reviews are not dependent on comments/answers.

    Have you taken a look at what I've uploaded to my Github? I'm new to all this so I appreciate the feedback but not the rudeness/sarcasm.

  • rbrahmsonrbrahmson "You may say I'm a dreamer / But I'm not the only one" NY ✭✭✭

    @Rangerine - Please do not be offended by what seems to be sarcasm, derision, and other feedback that may seem like forum bullying. I suffered from the same and while it is unfortunate, ignoring it (don't even acknowledge it exists) is well worth it for in the long run you will learn a lot and find those who offer the best mentoring.

    I would recommend, however, that you take the advice given in good faith, like the one suggesting to use the basic example plugin as the source of your first plugin writing (either the example or one of the How to samples) - your life and those trying to help you will be so much easier.

    This specific feedback relates to your last comment, I didn't have time this weekend to look at your code and I am going to be busy in the coming days, so I make no promises to review your code - sorry for that.

  • @rbrahmson Thanks. I just wanted to get a feel for things first by modifying the QnA plugin.

    The next step is creating my own plugin for what I discussed above.

    I'll be busy too and in the meantime I've been reading up on PHP and reading though the vanillaforums documentation.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    @Rangerine said:
    @vrijvlinder I haven't published it.

    Oh ? What's this then? It looks like QnA but called NewReviewPlugin … by you

    https://github.com/Rangerine/NewReviewPlugin

    Have you taken a look at what I've uploaded to my Github?

    I did and that is why I suggested you change definitions because your idea , based on QnA makes QnA not be QnA anymore. Make sure you change all the names of the files to the new name you will call QnA…

    @rbrahmson said:

    @Rangerine - Please do not be offended by what seems to be sarcasm, derision, and other >feedback that may seem like forum bullying. I suffered from the same

    awe really ?? who ? lmfao!!

  • @vrijvlinder Yes. I was told to create a GitHub so others could view the code I was working on.

    It looks like QnA but called NewReviewPlugin because I used it as the basis for the plugin. See the contents and you'll notice I give credit to who wrote it.

    I have changed the names. I had originally uploaded the wrong folder (I had uploaded the QnA plugin folder instead of my NewReviewPlugin folder which is why everything looked wrong). I stripped almost everything from the QnA plugin code and left only the bits of code that performed the following:

    • Created a new thread titled New Review
    • Changed all the names of the new thread to new review and the like
    • Added a button in the drop-down list to post a new review

    I'm barely learning and I am slowly getting familiar with the syntax, vanillaforums documenation, and how it all goes together. I hope you all can be patient as eventually I hope to provide other newcomers with help and even submit wholly original plugins.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    I was told to create a GitHub so others could view the code I was working on.

    No you were encouraged to post the code here .

    @R_J said:

    @Rangerine said:
    Would you like to see my current code?

    For sure. You can either create a GitHub or bitbucket repo or simply post it here .

    Some people may not have github and if that is where you want the feedback you are leaving people out who want also learn how to use other plugins to make their own.

    The help forum is here… believe it or not, many people have asked and will ask the same questions you have, so you are helping others whether you realize it or not by posting here and working out the code here.

    Some people have slow internet and github does not work for them. They might have an old computer with out dated browsers and github is not going to work. Pastebin also no no. Because you can't guarantee the image or code will be around forever. But it will be here forever. Because they never throw anything out. ;)

  • edited May 2016

    @vrijvlinder Posting all those separate chunks of code was a chore and didn't work out with the pair of " ` "s. See for yourself. I was instructed to create a GitHub or post the code here which I tried first.

    Some people may not have Github which is why mines is public. You don't even need an account to view the code. Its much neater and organized on Github. No one is left out, if you can load these forums you can load the Github webpage. Github will outlast vanillaforums, so we are good on that end.

  • R_JR_J Ex-Fanboy Munich Admin

    @Rangerine: everything is fine. If you prefer to work on GitHub that's okay, since the whole Vanilla project is on GitHub.

    If you prefer to study a plugin and modify it, because that is the way you feel comfortable. It is also fine.
    I'm not happy with that because in order to help you I would have to read and understand code that neither you nor I need. I'm also a strong believer that writing from scratch offers more chances to learn something than simply changing some lines. All in all I think in the best case you might end up with a really nice looking Frankenstein plugin when you could have born a new baby plugin, but that's really up to you ;)

    I'll see it as a bunch of questions. Some of them concerning an existing plugin and some of them concerning new code. I'm not happy with that, but it's really not up to you to make me or someone else around here happy.

    You said you are not ready to write a plugin from scratch, but believe me: it is easier to write a simple plugin and enhance it step by step than than modifying a quite complex plugin. But again: it is up to you and you have made your decision (but it is not too late and you can still change your mind...)

    I have not really taken a look at your repo because I thought you just forked it by then. I'll take a look at it again and see if I can add some comments or code or whatever.

  • hgtonighthgtonight ∞ · New Moderator

    @vrijvlinder said:

    @Rangerine said:
    @vrijvlinder I haven't published it.

    Oh ? What's this then? It looks like QnA but called NewReviewPlugin … by you

    https://github.com/Rangerine/NewReviewPlugin

    It doesn't matter if he published it. He left the copyright notice, the license, and the original author comments in there. This is all that is required under GPLv2 (along with licensing derivatives in a compatible license).

    Plenty of software starts as forks. If you look at yaga's repo, you will notice the first commit is by Todd Burry. I based Latest Post List (my first addon) on Who's Online.

    For what it is worth, it is a lot easier to inspect known working code and tweak it to fit because you get immediate results. I agree that starting with a fresh plugin is better from a learning perspective. You also don't have the growing pains when you realize the original approach was not a good fit for you.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Just to give an update and to say thanks for dealing with my growing pains:

    I used the pre-built settings in YAGA to have a button moderators can click on a thread when it is a 'review'. This awards the user with a premium credit redeemable in the MarketPlace for premium account access. YAGA takes care of the rest of the data beautifully. So when you click on the user's profile, you see all the reviews they've written under the review reactions link.

    My modified plugin to start a 'New Review' is working well. The only thing I have left is to create a 'Review Form' which appears when the 'New Review' thread is initiated. I know it goes in the discussionoptions.php section of the plugin but I am at a loss as how to integrate an HTML or PHP form to that.

    @hgtonight and @R_J , I definitely agree it is which is why I plan on writing my own plugins from scratch eventually .

Sign In or Register to comment.