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?

Hi again

I liked this plugin a lot!
But now I need to be able to display the latest post separated by categories, is it possible?

Thanks in advance.

«1

Comments

  • hgtonighthgtonight ∞ · New Moderator

    Do you want to have multiple modules on the same page?

    Do you want to pick a specific category?

    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.

  • Yes, I want the latest post of two of the categories, display in different modules.
    Like:

    Categorie 1:

    -This post

    -This post

    Categorie 2:

    -This post

    -This post

  • hgtonighthgtonight ∞ · New Moderator

    What version number of Vanilla are you running?

    You will have to modify the module itself to take in a category parameter, then you will have to add an instance of the module for each category you want.

    Then you have to modify the AJAX request to understand a category parameter as well. You could probably streamline the JS to have a single request for every module on the page.

    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.

  • I'm on Vanilla 2.1

    Is there a past discussion that explains how to take in a category parameter?

  • R_JR_J Ex-Fanboy Munich Admin

    @vrijvlinder said:
    Look at the categoriesmoduleplus plugin !

    http://vanillaforums.org/addon/categoriesmoduleplus-plugin

    That's a truly nice addon and it has a gorgeous icon, too! ;)
    But I think it's not what alanLeyva was searching for.

    @hgtonight said:
    What version number of Vanilla are you running?

    You will have to modify the module itself to take in a category parameter, then you will have to add an instance of the module for each category you want.

    Then you have to modify the AJAX request to understand a category parameter as well. You could probably streamline the JS to have a single request for every module on the page.

    Couldn't you just change that function (and for certain the html output)?

    public function SetData($Limit = 5, $Link = 'discussions') {
       $DiscussionModel = new DiscussionModel();
       $this->_LatestPosts = $DiscussionModel->Get(0, $Limit, 'all');
       $this->_Link = $Link;
    }
    

    I guess there would be a subselect needed for this (which I can't think of right now)

  • hgtonighthgtonight ∞ · New Moderator

    Just add a wheres array instead of using all.

    $CatID = 2;
    $DiscussionModel->Get(0, $Limit, array('CategoryID' => $CatID));
    

    Then you have to either disable the AJAX refresh or make it understand categories too.

    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.

  • R_JR_J Ex-Fanboy Munich Admin

    @hgtonight said:
    Just add a wheres array instead of using all.

    $CatID = 2;
    $DiscussionModel->Get(0, $Limit, array('CategoryID' => $CatID));
    

    Then you have to either disable the AJAX refresh or make it understand categories too.

    That would add up to one query per category. But with GetSelect it should be able to create one UNION ALL query for that

  • hgtonighthgtonight ∞ · New Moderator
    edited May 2014

    @R_J, my understanding is @alanLeyva‌ wanted multiple modules each with a separate category.

    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.

  • R_JR_J Ex-Fanboy Munich Admin

    @alanLeyva said:
    Yes, I want the latest post of two of the categories, display in different modules.

    You are obviously right. Forget what I've said...

  • hgtonighthgtonight ∞ · New Moderator

    @R_J said:
    You are obviously right. Forget what I've said...

    You need to dust off your crystal ball. ;)

    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.

  • R_JR_J Ex-Fanboy Munich Admin

    Crystal ball? Me? Nope, and I guess I've proven that I haven't earned one :D

  • hgtonighthgtonight ∞ · New Moderator

    Ah... you must have been off shaving that Yak when the gypsy woman was in town selling the crystal balls.

    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.

  • R_JR_J Ex-Fanboy Munich Admin

    You can't imagine how proud I am. I've even considered getting myself a button for my jacket

  • wow!

    Thanks guys
    This actually works.

    Great plugin BTW

  • ...Wait

    But now how can I make it 3?
    I need to display a "Category 1 Latest Post", "Category 2 Latest Post" and a "Latest Post"

    I have on my main template (.tpl) this:

    {asset name="Cat1"}- {asset name="Cat2"}- {asset name="Latest"}

    And I modified this:

    public function AssetTarget() {
    return 'Cat1';
    }

    But don't know how to make 3 of those, with the different $CatID as you suggested

  • hgtonighthgtonight ∞ · New Moderator

    @alanLeyva‌ do you want these modules on every front-end page?

    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.

  • No, I manage to create a sort of homepage with another plugin
    that's where I put the "asset"s

  • hgtonighthgtonight ∞ · New Moderator

    What plugin did you use?

    Generally you create a new instance of the module, then specify the asset when you add it to the controller.

    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.

  • alanLeyvaalanLeyva New
    edited May 2014

    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.

    Can you give me more details on how to crete a new instance of the module? I'm not quite sure how to do that.

Sign In or Register to comment.