2.1 Show recent discussions for one category using class.discussionsmodule.php?
I am using 2.1a35. Is there an easy way to modify the code in the file, class.discussionsmodule.php to show only a certain categories' recent discussions instead of all the categories.
class DiscussionsModule extends Gdn_Module {
public $Limit = 4;
public $Prefix = 'Discussion';
public function __construct() {
parent::__construct();
$this->_ApplicationFolder = 'vanilla';
}
public function GetData($Limit = FALSE) {
if (!$Limit)
$Limit = $this->Limit;
$DiscussionModel = new DiscussionModel();
$this->SetData('Discussions', $DiscussionModel->Get(0, $Limit, array('Announce' => 'all')));
}public function AssetTarget() {
return 'Panel';
}public function ToString() {
if (!$this->Data('Discussions')) {
$this->GetData();
}
require_once Gdn::Controller()->FetchViewLocation('helper_functions', 'Discussions', 'Vanilla');
return parent::ToString();
}
}
Comments
You don't have to edit any core files to do this. Simply use the
DiscussionModel
class to get the data you'd like:The above example will get you the first 20 discussions from the category with the ID of 100.
Kasper Kronborg Isager (kasperisager) | Freelance Developer @Vanilla | Hit me up: Google Mail or Vanilla Mail | Find me on GitHub
@kasperisager Thank you very much, that does exactly what i need
Cool, glad I could be of help!
P.S.: If you need help displaying the data, just say the word.
Kasper Kronborg Isager (kasperisager) | Freelance Developer @Vanilla | Hit me up: Google Mail or Vanilla Mail | Find me on GitHub