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.

Display Latest Post by categories?

2»

Comments

  • hgtonighthgtonight ∞ · New Moderator

    Since you are using Basic Pages and a custom theme, put the following in your theme hooks file:

    public function PageController_Render_Before($Sender) {
      $Module = new LatestPostListModule();
      $Module->SetData(5, 'categories/1', 1);
      $Sender->AddModule($Module, 'Cat1');
    
      $Module = new LatestPostListModule();
      $Module->SetData(5, 'categories/2', 2);
      $Sender->AddModule($Module, 'Cat2');
    
      $Module = new LatestPostListModule();
      $Module->SetData();
      $Sender->AddModule($Module, 'Latest');
    }
    

    And replace the SetData() method in /plugins/LatestPostList/modules/class.latestpostlistmodule.php with:

    public function SetData($Limit = 5, $Link = 'discussions', $CategoryID = NULL) {
      $Wheres = (!is_null($CategoryID) && is_numeric($CategoryID)) ? array('CategoryID' => $CategoryID) : '';
      $DiscussionModel = new DiscussionModel();
      $this->_LatestPosts = $DiscussionModel->Get(0, $Limit, $Wheres);
      $this->_Link = $Link;
    }
    

    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.

  • Thank you very much @hgtonight !

    That was it.

    Maybe considering put that feature onto the default plugin wold be nice.

    Thank you once again.

  • Sorry to bother you once again.

    How can I target to the ParentCategoryID?

    I tried with this

    Changing $CategoryID to $ParentCategoryID.
    But that did't work

    Hope you can help.

  • hgtonighthgtonight ∞ · New Moderator

    Just pass in the parent category ID in your theme hooks 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.

  • it didn't work
    I guess is because we don't have any discussion in the parent category itself.

    I try making an array of the subcategories of the same parent category.
    But that did't work either.

    Is there a we to target the parent category id instead of just every single category?

    My DB looks like this

    lets say I need to target to the number 8 parent ID

  • hgtonighthgtonight ∞ · New Moderator

    Oh, you want to display posts from a specific category AND it's sub-categories.

    Do your parent categories only acting as headings, or can you post in them as well?

    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.

  • businessdadbusinessdad Stealth contributor MVP

    @hgtonight said:
    Oh, you want to display posts from a specific category AND it's sub-categories.

    That can be done easily. See my previous answer about navigating the category tree.

  • hgtonighthgtonight ∞ · New Moderator

    This is definitely beyond the scope of my plugin, but you just need to to modify the LatestPostListModule::SetData() method to do what you want.

    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.

  • edited December 2014

    @alanLeyva said:
    The plugin is "Basic Pages" (an application actually)
    I just overwrite the index.php file for a custom index.tpl file, the .tpl was so I can put the "asset"s to print the categories latest post.

    @alanLeyva can you elaborate more on how you used the "Basic Pages" application to bring about your desired result? Where is the location of the index.php file you overwrote?

Sign In or Register to comment.