[XenMods] Announcements [Deleted]

It is better, but some display issues. See attached file.
 

Attachments

  • index.webp
    index.webp
    390.7 KB · Views: 29
Code:
<?php
class PHCannouncements_Model_Threads extends XenForo_Model
{
    function Announcements()
    {
        $ThreadModel = XenForo_Model::create('XenForo_Model_Thread');
        $ForumModel = XenForo_Model::create('XenForo_Model_Forum');
        $_getThreads = $this->_getDb()->fetchAll("SELECT thread.thread_id as thread_id, thread.node_id
            FROM xf_thread as thread
            WHERE thread.sticky = 2
            ORDER BY thread.last_post_date DESC"
        );
       
        $Threads = array();
       
        for ($i = 0; $i < count($_getThreads); $i++)
        {
            $Forum = $ForumModel->getForumById($_getThreads[$i]['node_id']);
            if (is_array($Forum))
            {            
                $Thread = $ThreadModel->prepareThread($ThreadModel->getThreadById($_getThreads[$i]['thread_id'], array('join' => 17)), $Forum);
                $Thread['canInlineMod'] = false;
                $Thread['canEditThread'] = false;
                $Threads[] = $Thread;
            }
        }
       
       
        return $Threads;
    }
    function Stickies()
    {        
        $ThreadModel = XenForo_Model::create('XenForo_Model_Thread');
        $ForumModel = XenForo_Model::create('XenForo_Model_Forum');
       
        $_getThreads = $this->_getDb()->fetchAll("SELECT thread.thread_id as thread_id, thread.node_id
            FROM xf_thread as thread
            WHERE thread.sticky = 1
            ORDER BY thread.last_post_date DESC"
        );
       
        $Threads = array();
       
        for ($i = 0; $i < count($_getThreads); $i++)
        {
           
            $Forum = $ForumModel->getForumById($_getThreads[$i]['node_id']);
            if (is_array($Forum))
            {            
                $Thread = $ThreadModel->prepareThread($ThreadModel->getThreadById($_getThreads[$i]['thread_id'], array('join' => 17)), $Forum);
                $Thread['canInlineMod'] = false;
                $Thread['canEditThread'] = false;
                $Threads[] = $Thread;
            }
        }
       
       
        return $Threads;
    }
}

Try this as file: /upload/library/PHCannouncements/Model/Threads.php
 
My bad, didn't include the css in the xml file. You're going to have to reinstall the new package I put up in a minute (if you want you can just use the xml as that's the only thing that changed for you but the fix that we've been discussing for your other error is being included also)
 
Thank you Daniel, it is working.
Any way to move the block, as displayed in the attached screen ?
 

Attachments

  • index.webp
    index.webp
    87.1 KB · Views: 33
Yes but you have to find the template hook you want to use (look at the forum_list_nodes template and find xen:hook). Once you find which one you want to use go to:

/upload/library/PHCannouncements/listeners/Hook.php

change

Code:
if ($hookName == 'forum_list_nodes' || $hookName == 'forum_view_pagenav_before')

to the hook names you want to use (forum_view_pagenav_before) is when you click on a node.
 
@Daniel Hood
(First thank you for this. I've been looking around forever for a feature like this. It is so annoying when you want to have an important thread in ALL FORUMS and can't. So this add-on is great so thank you for making it)

My questions are

1. I skimmed through the posts in this thread so this may have been answered already but is this compatible with 1.2?

2. I read somewhere in this thread that there was some issues with Post Ratings add-on and USername rich everywhere? I use both of these add-ons so would i be able to use yours without any issues.

3. With the updated version you just added today, do I need to do any of the manual edits that you suggested the other user above do ?

Thanks so much.
 
You're welcome,

1) Yes, I actually developed it on 1.2 Beta 3 (I haven't tested any higher but I imagine it works)

2) and 3) these are connected, I fixed both things with his testing and repackaged it so the newest version does have it fixed. The only edit you might have to do is the template hook one but that's only if you don't like the positioning of it by default.
 
@Daniel Hood you're welcome, i feel normal to give feedback on a free plugin i use.
I changed the hook and it displays now ok.
Another issue : in the pined topic list in your plugin panel, there are some pined thread missing. How does your plugin browse pined thread ? (I have a pined poll thread which does not appear for ex)
 
Those are probably the threads that were erroring before, can you find anything that all threads missing have in common
 
Hi @Daniel Hood, you listened to load class event for XenForo_DataWriter_Discussion_Thread but implemented PHCannouncements_DataWriter_Thread the wrong way...

PHP:
class PHCannouncements_DataWriter_Thread extends XenForo_DataWriter_Discussion_Thread

Should be

PHP:
class PHCannouncements_DataWriter_Thread extends XFCP_PHCannouncements_DataWriter_Thread

For more information, please read here: http://xenforo.com/community/threads/creating-an-addon.5416/
 
Hmm, I will look into that. Thanks.
This exists in all of your add-ons. Any where where you are extending a XenForo class, if you use listeners, they should be extending XFCP_CLASSNAME, and XenForo will handle resolving them and extending the proper classes. This allows multiple add-ons to extend the same class.

You already have the listeners set up, you should just have to change what they extend.

Daniel, if you would like an explaination, I have just added a resource that explains the Proxy System:
http://xenforo.com/community/resources/understanding-the-xenforo-class-proxy-system.2080/
 
Last edited:
Top Bottom