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.

simple tweak to default to "start a discussion"?

edited November 2011 in Vanilla 2.0 - 2.8
hi, i've seen this come up before without a detailed response, so nudging the question here:

is there a simple way to set the plugin behavior so that the default behavior for a user clicking on "start a discussion" is actually "start a discussion" with an option to "ask a question"? (right now, as most are aware, it defaults to "ask a question" and inserts that text above the input box, creating possible confusion for a user

alternatively, would it be possible to separate out the action such that a *new* button is inserted in the upper right (default theme example) below "start a discussion" that says" ask a question"? i was thinking about doing this with "pockets" but am not sure what code snippet would go there, nor how i would then remove the option from the standard "start a discussion" link prompting a user to once again "ask a question"

Answers

  • ToddTodd Chief Product Officer Vanilla Staff
    There is no option for this no. We'll take a pull request if you want to enhance the plugin.
  • @ passing notes

    I'm too waiting for a similar functionality. Pls let me know if you have made some progress on this.

  • fh111fh111 Vanilla Padawan ✭✭

    i would be happy to know how to default to start a discussion too.

  • hbfhbf wiki guy? MVP
    edited December 2011

    I didn't look into how to make this an "option" in the plugin itself, but to change the default

    open class.qna.plugin.php
    and change line 395:

    from: $Form->SetValue('Type', 'Question');
    to: $Form->SetValue('Type', 'Discussion');

    you can also change the order the tabs are displayed by modifying qnapost.php

    and swapping the order of lines 15 and 16.

    I just implemented this on my forum.

    homebrewforums.net you can test it out if you like.

  • fh111fh111 Vanilla Padawan ✭✭
    edited December 2011

    i figured it out myself in case anyone needs the code, here it is

    change in class.qna.plugin.php line 412 to 414 from

            $Form->SetValue('Type', 'Question');
         } elseif (!$Form->GetValue('Type')) {
            $Form->SetValue('Type', 'Discussion');
    

    to

            $Form->SetValue('Type', 'Discussion');
         } elseif (!$Form->GetValue('Type')) {
            $Form->SetValue('Type', 'Question');
    

    that works for me so far

    edit:
    oh i did not reload the page before posting : )
    thanks for your reply though

  • hbfhbf wiki guy? MVP

    fh111 said:
    i figured it out myself in case anyone needs the code, here it is

    change in class.qna.plugin.php line 412 to 414 from

            $Form->SetValue('Type', 'Question');
         } elseif (!$Form->GetValue('Type')) {
            $Form->SetValue('Type', 'Discussion');
    

    to

            $Form->SetValue('Type', 'Discussion');
         } elseif (!$Form->GetValue('Type')) {
            $Form->SetValue('Type', 'Question');
    

    that works for me so far

    edit:
    oh i did not reload the page before posting : )
    thanks for your reply though

    i would not change line 414. if i'm reading the code right, it's a failsafe condition that originally said, if you can't get the value of Type from the page, just default to the standard discussion because something is wrong. In my code i have both lines setting the value to Discussion.

    maybe @todd can check my understanding of the code.

  • fh111fh111 Vanilla Padawan ✭✭

    thanks for letting me know, i did not realize that

  • before changing i can only start questions

    after changing i can only start discussions

    in case of hbf with two lines 'Discussion' i can start only a discussion, too

    $Form->SetValue('Type', 'Discussion'); } elseif (!$Form->GetValue('Type')) { $Form->SetValue('Type', 'Discussion');

    onclick the Buttons "Ask a Question" or "start Discussion" happens nothing

    i think there is an function missing, but which

    My Vanilla Version 2.0.18.1

  • So, which is the best way to implement this functionality because if you are using the mobile theme, users do not have the opportunity to start a discussion at all.

  • I'd vote for the 'ask a question' button in the top right under the 'start a discussion' button too please. Needs to be clear from the beginning for my users and the current format isn't.

    Thank you :)

  • edited March 2012

    Not to resurrect a dead topic but this seems to work... also had to reorder the buttons as @hbf had suggested

    public function PostController_Render_Before($Sender, $Args) {
    $Form = $Sender->Form; //new Gdn_Form();
    $QuestionButton = !C('Plugins.QnA.UseBigButtons') || GetValue('Type', $_GET) == 'Question';
    if (!$Form->IsPostBack()) {
    //if (!property_exists($Sender, 'Discussion')) {
    if (!property_exists($Sender, 'Question')) {
    //$Form->SetValue('Type', 'Question');
    $Form->SetValue('Type', 'Discussion');
    } elseif (!$Form->GetValue('Type')) {
    $Form->SetValue('Type', 'Question');
    //$Form->SetValue('Type', 'Discussion');
    }
    }
    
    if ($Form->GetValue('Type') == 'Question' && $QuestionButton) {
    $Sender->SetData('Title', T('Ask a Question'));
    }
    }
    
  • estest New
    edited May 2012

    I did the same as @Waterskiaddict - changed 411 line to @hbf suggestion:

    - if (!property_exists($Sender, 'Discussion')) {
    + if (!property_exists($Sender, 'Question')) {
    

    And now Start a discussion option is chosen by default.

    But the order of the buttons is still the same - Ask a Question still comes first. And I wonder how do I change this?

  • hbfhbf wiki guy? MVP
    edited May 2012

    est said:
    I did the same as @Waterskiaddict - changed 411 line to @hbf suggestion:

    - if (!property_exists($Sender, 'Discussion')) {
    + if (!property_exists($Sender, 'Question')) {
    

    And now Start a discussion option is chosen by default.

    But the order of the buttons is still the same - Ask a Question still comes first. And I wonder how do I change this?

    Your question was answered previously...

    hbf said:

    you can also change the order the tabs are displayed by modifying qnapost.php

    and swapping the order of lines 15 and 16

    Did you do this?

  • estest New
    edited May 2012

    OMG, I've totally misunderstood all messages :(

    First, I thought that post with code lines was yours, but it belongs to @fh111. Second I have not noticed your comment about the line 414 - and I agree with you, that line should not be changed. And finally, I have not noticed your remark about swapping the order of lines 15 and 16 - it helped me to change the order of the buttons.

    Please, forgive me and thank you so much!

  • hbfhbf wiki guy? MVP

    est said:
    OMG, I've totally misunderstood all messages :(

    First, I thought that post with code lines was yours, but it belongs to @fh111. Second I have not noticed your comment about the line 414 - and I agree with you, that line should not be changed. And finally, I have not noticed your remark about swapping the order of lines 15 and 16 - it helped me to change the order of the buttons.

    Please, forgive me and thank you so much!

    No worries. Glad it worked for you.

Sign In or Register to comment.