1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Thread Prefixes with titles... extends XFCP_EWRatendo_Model_Thread not extending

Discussion in 'XenForo Development Discussions' started by tenants, May 22, 2012.

  1. tenants

    tenants Well-Known Member

    Something strange going on here.

    I thougth I would add titles to the thread prefix_ids for the URL, and since I'm customising EWRatendo, I thought I would add the
    listener here / using the existing one (it shouldn't make any differance)

    what I've done, is use the existing listener:

    Code:
    <?php
     
    class EWRatendo_Listener_Model
    {
        public static function post($class, array &$extend)
        {       
            if ($class == 'XenForo_Model_Thread')
            {
              $extend[] = 'EWRatendo_Model_Thread';
            }
            if ($class == 'XenForo_Model_Post')
            {
                $extend[] = 'EWRatendo_Model_Post';
            }
        }
    }
    and overriden the function of intrest:

    Code:
    <?php
     
    class EWRatendo_Model_Thread extends XFCP_EWRatendo_Model_Thread
    {
        public function getThreadsInForum($forumId, array $conditions = array(), array $fetchOptions = array())
        {
        var_dump('test');
            $threads = parent::getThreadsInForum($forumId, $conditions, $fetchOptions);
            $prefixModel = $this->getModelFromCache('XenForo_Model_ThreadPrefix');
            foreach ($threads AS &$thread)
            {
                $prefix = new XenForo_Phrase($prefixModel->getPrefixTitlePhraseName($thread['prefix_id'])); 
                $thread['prefix_url'] = XenForo_Link::getTitleForUrl($prefix, true);
         
            }
            return $threads;
        }
     
    }
    
    all that was left for me to do was to add the prefix_url inside the thread_list_item template here:


    Code:
                        <xen:if is="{$linkPrefix}">
                            <a href="{xen:link forums, $forum, 'title={$thread.prefix_url}', 'prefix_id={$thread.prefix_id}'}" class="prefixLink"
                                title="{xen:phrase show_only_threads_prefixed_by_x, 'prefix={xen:helper threadPrefix, $thread, plain, ""}'}">{xen:helper threadPrefix, $thread, html, ''}</a>
                        <xen:else />
    This works,
    (thread prefixs now have a url sucha as:
    http://localhost/xenforo/index.php?forums/events.13/&title=my-prefix-title&prefix_id=3)


    however... it only works locally oO.... ?!?

    If I stick a var_dump inside the listener, the XenForo_Model_Thread is extendended (both on my test windows server and my live unix server)

    If I stick a var_dump inside the extended function getThreadsInForum, it only gets dumped out by the local windows version... very bizarre????
     
  2. tenants

    tenants Well-Known Member

    Okay, I've seperated this out as it's own plugin and it still acts the same..

    Extends on my local box, but on my live linux box, it doesn't extend. I've attached the example as a plugin

    It's possibly something silly, but just seem very strange at the moment
     

    Attached Files:

  3. tenants

    tenants Well-Known Member

    Or ... getThreadsInForum isn't called on my live envorment (that's kind of what this suggests if everything is working... humph)
     
  4. tenants

    tenants Well-Known Member

    Ignore, it was caused by another plugin... the above works fine for adding a tittle to thread prefixes (if anyone feels they need this ;))
     

Share This Page