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 to Display Discussion from all the Categories except one on Discussions page?

2»

Answers

  • sahotataransahotataran Developer, Bay Area - CA ✭✭✭
    sure @ddumont - i will be submitting the working example and also the demo URL soon - as soon as i finish out with the layout and stuff - CSS. i will send you the whole code i had used and then you can consider it putting into your working example of NillaBlog.

    Thanks

    There was an error rendering this rich post.

  • sahotataransahotataran Developer, Bay Area - CA ✭✭✭
    @ddumont i had a quick question - is there anyway i can set the number of discussions to be displayed on the BLOG category page?
    e.g generally we set the number of discussions we can show on category page through Dashboard->Forum->Advanced
    but suppose if it choose 50 there and if we try to display 50 posts in NillaBlog Category then the page is going to get very very long.
    so is there anyway we can restrict the BLOG category page discussions count to only 10 or 15?????
    Thanks

    There was an error rendering this rich post.

  • NillaBlog has an option in the plugin config that lets you say how many posts you want to display instead of the global number, yes.

    There was an error rendering this rich post.

  • sahotataransahotataran Developer, Bay Area - CA ✭✭✭
    Thanks ddumont i just downloaded the latest version. thanks again.
    i have a hack to display images if a user attaches an image with the post. shall i pm to u?

    There was an error rendering this rich post.

  • This is not very MVC, You are using a view for your logic. Views should be kept clean and should only concern display issues (and some formatting issues too). There are some forgiveable exceptions but this is way overboard.

    Likely there is better way to do this.

    grep is your friend.

  • x00x00 MVP
    edited November 2011
    DisscussionModel_BeforeGet_Handler

    You should be able to set

    $Sender->SQL->Limit($Limit, $Offset); over-riding the default.

    also wheres

    You can use if(strtolower($Sender->RequestMethod) != 'index') return; before that.

    Have a look a class.discussionmodel.php Get you see the BeforeGet event, you even have wheres event args

    grep is your friend.

  • sahotataransahotataran Developer, Bay Area - CA ✭✭✭
    @ddumont
    i restricted my home page to display only 10 latest posts which are not from my BLOG category using the hook in themes as below:
     public function DiscussionsController_Render_Before($Sender) {
    $this->_AddButton($Sender, 'NewDiscussionModule');
    $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; }
    if ($pageURL == 'MY HOME PAGE URL') {
    $Offset = 0;
    $Limit = 10;
    $Whereas = array("CategoryID <>" => 'MY BLOG CATEGORY ID' );
    $DiscussionModel = new DiscussionModel();
    $Sender->DiscussionData = $DiscussionModel->Get($Offset, $Limit, $Whereas);
    $CountDiscussions = count($DiscussionModel->Get($Offset, $Limit, $Whereas));
    $Sender->Data('Discussions', $Sender->DiscussionData);
    $Sender->SetData('CountDiscussions', $CountDiscussions);
    /* ======= this was the code given by x00 =========
    list($Page, $Limit) = OffsetLimit(10, 0);
    $Discussions = $Sender->Data('Discussions');
    $DiscussionsFiltered =array();
    foreach($Discussions As $Discussion ){
    if($Discussion->Category!=='articles'){
    $DiscussionsFiltered[]=$Discussion;
    }
    }
    $DiscussionsLeft = count($DiscussionsFiltered);
    //$DiscussionsFiltered = new Gdn_DataSet($DiscussionsFiltered);
    $Sender->DiscussionData =$DiscussionsFiltered;
    $Sender->Data('Discussions',$DiscussionsFiltered);
    ===============================*/
    }

    }

    There was an error rendering this rich post.

Sign In or Register to comment.