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.

How enable in only one category

Hello! This plugin is very nice!

So i wonder if is possible to show the "Ask a Question" Button in only one category

Exemple: Only show in "Have a Question" Category?

Thanks for the atention! Have a good night!

Tagged:

Comments

  • The "Ask a Question" button is displayed via the NewQuestionModule. In /plugins/QnA/class.qna.plugin.php, I created a new method called _AddNewQuestionModule() like so:

    private function _AddNewQuestionModule($Sender) {
     $CategoryID = $Sender->CategoryID;
     if(C('Plugins.QnA.CategoryID') != $CategoryID) {
       return;
     }
     if(C('Plugins.QnA.UseBigButtons')) {
       $QuestionModule = new NewQuestionModule($Sender, 'plugins/QnA');
       $Sender->AddModule($QuestionModule);
     }
    }
    

    Then I replaced the following lines with $this->_AddNewQuestionModule($Sender):

    if(C('Plugins.QnA.UseBigButtons')) {
      $QuestionModule = new NewQuestionModule($Sender, 'plugins/QnA');
      $Sender->AddModule($QuestionModule);
    }
    

    Finally, I added the following to the /conf/config.php file:

    $Configuration['Plugins']['QnA']['UseBigButtons'] = TRUE;
    $Configuration['Plugins']['QnA']['CategoryID'] = 2;
    

    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.

  • @hgtonight‌ Hi thanks answer. But now the QnA plugin dont enable.

  • @multplaneta said:
    hgtonight‌ Hi thanks answer. But now the QnA plugin dont enable.

    here say: The addon could not be enabled because it generated a fatal error:

  • If you could post the error, I could help you debug it.

    If someone else could try my changes for some more data points, I would appreciate it.

    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.

  • Only appear that: The addon could not be enabled because it generated a fatal error:

    Dont show the error, and another thing wen i edit the class.qna.plugin.php with

    private function _AddNewQuestionModule($Sender) { $CategoryID = $Sender->CategoryID; if(C('Plugins.QnA.CategoryID') != $CategoryID) { return; } if(C('Plugins.QnA.UseBigButtons')) { $QuestionModule = new NewQuestionModule($Sender, 'plugins/QnA'); $Sender->AddModule($QuestionModule); } }

    give a sintax error at Dreamweaver

  • @hgtonight‌ i what line i add you method?

  • You can put it anywhere as long as it is in the class declaration and not in any other method.

    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.

  • @hgtonight‌ now i can enable the plugin, but i still see the button in all categories.

    Sorry for the trouble! And tanks for the atention!

  • Please post your modified file.

    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.

  • 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.

  • @hgtonight‌ Thanks, now i have to category ID in this:

    $Configuration['Plugins']['QnA']['CategoryID'] = 2;

    If I have, where i find the ID of the category?

    Thanks for the patience!

  • Load up the category on your site. The URL should look something like: http://forums.example.com/categories/the-watercooler

    Once you have the category you like displayed, append .json to the controller to view the underlying data. E.g. http://forums.example.com/categories.json/the-watercooler

    The CategoryID should be the first item.

    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.

  • @hgtonight‌ Thanks, is working, you are Awsome!!!!!!

Sign In or Register to comment.