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

Having trouble with recent updated threads module...

Discussion in 'XenForo Development Discussions' started by Jaxel, Oct 29, 2010.

  1. Jaxel

    Jaxel Well-Known Member

    example: http://xen1.8wayrun.com/portal/

    here is the public controller for that page:
    Code:
    <?php
    
    class EWRporta_ControllerPublic_Portal extends XenForo_ControllerPublic_Abstract
    {
    	public function actionIndex()
    	{
    		$visitor = XenForo_Visitor::getInstance();
    
    		$conditions = array();
    		$fetchOptions = array(
    			'join' => XenForo_Model_Thread::FETCH_FORUM | XenForo_Model_Thread::FETCH_USER,
    			'readUserId' => $visitor['user_id'],
    			'postCountUserId' => $visitor['user_id'],
    			'order' => 'last_post_date',
    			'limit' => 2,
    		);
    
    		$threads = $this->getModelFromCache('XenForo_Model_Thread')->getThreads($conditions, $fetchOptions);
    
    		foreach ($threads AS &$thread)
    		{
    			$thread = $this->getModelFromCache('XenForo_Model_Thread')->prepareThread($thread, $thread);
    			$thread['canInlineMod'] = false;
    			$thread['canEditThread'] = false;
    		}
    
    		$viewParams = array(
    			'visitor' => $visitor,
    			'threads' => $threads,
    			'showForumLink' => 'true',
    			'newsList' => $this->getModelFromCache('EWRporta_Model_Threads')->getRecent(),
    		);
    
    		return $this->responseView('EWRporta_ViewPublic_Portal', 'EWRporta_Portal', $viewParams);
    	}
    }
    The template is as follows:
    Code:
    <xen:if hascontent="true">
    <div class="discussionList section sectionMain">
    
    	<dl class="sectionHeaders">
    		<dt class="posterAvatar"></dt>
    		<dd class="main">
    			<a class="title"><span>{xen:phrase title}</span></a>
    			<a class="postDate"><span>{xen:phrase start_date}</span></a>
    
    		</dd>
    		<dd class="stats">
    			<a class="major"><span>{xen:phrase replies}</span></a>
    			<a class="minor"><span>{xen:phrase views}</span></a>
    		</dd>
    		<dd class="lastPost"><a><span>{xen:phrase last_message}</span></a></dd>
    	</dl>
    
    	<ol class="discussionListItems">
    		<xen:contentcheck>
    		<xen:foreach loop="$threads" value="$thread">
    			<xen:include template="thread_list_item" />
    		</xen:foreach>
    		</xen:contentcheck>
    	</ol>
    </div>
    </xen:if>
    Inside "thread_list_item", some avatars are built for the thread view. The avatars show up fine, but it produces errors that you can see on the page linked above.
     
  2. Jaxel

    Jaxel Well-Known Member

    fixed it...

    changed:
    Code:
    $visitor = XenForo_Visitor::getInstance();
    to:

    Code:
    $visitor = XenForo_Visitor::getInstance()->toArray();
     
  3. Jaxel

    Jaxel Well-Known Member

    I do have another question though... how do I limit the getThreads() funtion from getting deleted/moderated threads?

    Figured it out:
    Code:
    		$conditions = array(
    			'deleted' => false,
    			'moderated' => false,
    		);
     

Share This Page