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.

Announce post in a single fixed category

I have created a separate category where i want only announced post to appear. I want to do this in such a way that i don't change the main category of the post. So if post "abcdef" belongs to category "xyz". It can also belong to category "123" where it is announced without losing its initial "abcdef" category.

Please anyone know how i can achieve this? I'm just a beginner in web programming with full html and css knowledge

Comments

  • hgtonighthgtonight ∞ · New Moderator

    Sounds like a fairly simple modification to the ZeroCounts plugin: https://github.com/hgtonight/Plugin-ZeroComments/blob/master/class.zerocomments.plugin.php

    We want a new endpoint called announcements. It should act like a normal discussion page. There should be a link in the discussion filter menu to see this page.

      public function DiscussionsController_Announcements_Create($Sender, $Args = array()) {
        $this->CustomView = TRUE;
        $Sender->View = 'Index';
        $Sender->SetData('_PagerUrl', 'discussions/announcements/{Page}');
        $Sender->Index(GetValue(0, $Args, 'p1'));
      }
    
      public function DiscussionsController_Render_Before($Sender) {
        if($this->CustomView) {
          $Sender->SetData('CountDiscussions', Gdn::Cache()->Get('AnnouncementList-Count'));
        }
      }
    
      public function DiscussionsController_AnnouncementsCount_Create($Sender) {
        $Count = Gdn::SQL()->GetCount('Discussion', array('Announce' => 'is not 0'));
        Gdn::Cache()->Store('AnnouncementList-Count', $Count, array(Gdn_Cache::FEATURE_EXPIRY => 15 * 60));
        $Sender->SetData('UnrequitedCount', $Count);
        $Sender->SetData('_Value', $Count);
        $Sender->Render('Value', 'Utility', 'Dashboard');
      }
    
      public function Base_AfterDiscussionFilters_Handler($Sender) {
        $Count = Gdn::Cache()->Get('AnnouncementList-Count');
        if($Count === Gdn_Cache::CACHEOP_FAILURE) {
          $Count = ' <span class="Aside"><span class="Popin Count" rel="/discussions/announcementscount"></span>';
        }
        else {
          $Count = ' <span class="Aside"><span class="Count">' . $Count . '</span></span>';
        }
        echo '<li class="Announcements ' . ($this->CustomView === TRUE ? ' Active' : '') . '">' .
                Anchor(Sprite('SpUnansweredQuestions') . ' ' . T('Announcement List') . $Count,
                  '/discussions/announcements', 'Announcements') . '</li>';
      }
    
      public function DiscussionController_Render_Before($Sender) {
        if($this->CustomView === TRUE) {
          // blank out the discussions list
          $Sender->SetData('Discussions', array(), true);
        }
      }
    

    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.

  • @hgtonight i really appreciate your support and help. I get this so clearly. But how do i create the custom page where the result is displayed and how do i also set it as myhomepage.com by default

  • I've done exactly as you instructed but now i have both announcement and zero comments posts on same page. Please how do i exclude the zero comments posts and have only announcements posts listed. Plus, how do i make the announcements page the default landing page

  • hgtonighthgtonight ∞ · New Moderator

    Setting the announcements page to default is the same as setting the default page to anything else.

    1. Go to your dashboard
    2. Click on routes
    3. Edit the DefaultController route

    You will need to modify the plugin to not show the zero counts. It will take some work on your part, but I believe the difficult part is done.

    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 so much. I'll try my best. I'm really grateful

  • But i really wish u can help further

Sign In or Register to comment.