HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Please upgrade here. These earlier versions are no longer being updated and have security issues.

Article link in sidebar with notification

This discussion is related to the Articles addon.

Hi, im new to vanilla. I have recently added the article addon to my forum but noticed that the only way members know their is a new article is via the activity page. Would it be possible to add the Article link to the sidebar content (Under categories/activity links) and include a new article counter??

thanks, Lee

Comments

  • hgtonighthgtonight ∞ · New Moderator

    So... right there?

    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 @hgtonight that's what I'm looking for, as I mentioned my members don't actually know about published articles unless they check their activity feed.

    Thanks.

  • hgtonighthgtonight ∞ · New Moderator

    Create a plugin or add to the /applications/articles/settings/class.hooks.php file:

    public function Base_AfterDiscussionFilters_Handler($Sender) {
      echo Wrap(Anchor(Sprite('SpMessage') . ' ' . T('Articles'), '/articles'), 'li', array('class' => $Sender->ControllerName == 'articlescontroller' ? 'Articles Active' : 'Articles'));
    }
    

    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.

    AmboBleistivtShadowdare
  • thanks @hgtonight that works a treat. Can i ask if that includes the notification for a newly created article or would that function require more complex code.

    thanks

  • hgtonighthgtonight ∞ · New Moderator

    No.

    You would have to add a count popin. Not sure if Articles already has a count method public.

    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.

  • Ok thanks for your help so far.

  • ShadowdareShadowdare Moderator
    edited February 2015

    Thanks for the help, @hgtonight!

    @Ambo, you can show a count for the total number of published articles in the sidebar link, but there is no way to show the total number of unread ones at the moment.

    As a side note, if anyone needs this kind of functionality in Articles right now, they can look at how Vanilla implements it, add it into the code, and then send a pull request to the GitHub repo. It looks like the Vanilla app implements unread functionality by keeping track of unread comments AKA "comment watches."

    Add Pages to Vanilla with the Basic Pages app

  • Thanks @Shadowdare, showing the number of articles would be fine, i done a quick search but not sure how or where I could implement this, can you offer some help? Thanks.

  • @Ambo, give this a try:

        public function Base_AfterDiscussionFilters_Handler($Sender) {
            $ArticleModel = new ArticleModel();
            $CountArticles = $ArticleModel->GetCount(array('Status' => ArticleModel::STATUS_PUBLISHED));
            $CountPopin = ($CountArticles > 0) ? ' <span class="Aside"><span class="Count">' . BigPlural($CountArticles, '%s article') . '</span></span>' : '';
    
            echo Wrap(Anchor(Sprite('SpMessage') . ' ' . T('Articles') . $CountPopin, '/articles'), 'li',
                array('class' => ($Sender->ControllerName == 'articlescontroller') ? 'Articles Active' : 'Articles'));
        }
    

    Add Pages to Vanilla with the Basic Pages app

    R_JhgtonightAmboBleistivt
  • @Shadowdare said:
    Ambo, give this a try:

        public function Base_AfterDiscussionFilters_Handler($Sender) {
            $ArticleModel = new ArticleModel();
            $CountArticles = $ArticleModel->GetCount(array('Status' => ArticleModel::STATUS_PUBLISHED));
            $CountPopin = ($CountArticles > 0) ? ' <span class="Aside"><span class="Count">' . BigPlural($CountArticles, '%s article') . '</span></span>' : '';
    
            echo Wrap(Anchor(Sprite('SpMessage') . ' ' . T('Articles') . $CountPopin, '/articles'), 'li',
                array('class' => ($Sender->ControllerName == 'articlescontroller') ? 'Articles Active' : 'Articles'));
        }
    

    worked a treat @Shadowdare, thanks, i have a couple of other questions relating to your plugin, is it ok to ask them here??

    thanks.

    Shadowdare
  • ShadowdareShadowdare Moderator
    edited February 2015

    @Ambo, you're welcome! You can ask them here, but you should start a new discussion under the plugin's page if it's unrelated to this question, preferably.

    Add Pages to Vanilla with the Basic Pages app

    hgtonight
  • ok mate, will start new discussion.

Sign In or Register to comment.