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

Link to a users latest thread in a specific forum

Discussion in 'Styling and Customization Questions' started by Espen Espelund, Oct 21, 2011.

  1. Espen Espelund

    Espen Espelund Active Member

    We got an highly active journal forum, so most of the users got their own thread there. Are there some simple (non resource intensive) way to link to the users latest thread in that forum?
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    The latest post for each forum is linked on the index page. But that is a direct link by postid. There is no generic link for the last post in a forum.
     
  3. Espen Espelund

    Espen Espelund Active Member

    Guess another way to do it would be to run a hook when a user creates a thread there and update a custom user field (1.1). Can this be done? Didn't have a look at XenForo's hook system yet
     
  4. ragtek

    ragtek Guest

    I've needed something similar for my forum so i've coded an add-on for this.

    PHP:
                public function actionIntroduceThread()
                        {
                            
    $userId $this->_input->filterSingle('user_id'XenForo_Input::UINT);
                            
    $user $this->_getUserModel()->getUserById($userId);
                            if (!
    $user) {
                                return 
    $this->responseError(new XenForo_Phrase('requested_member_not_found'), 404);
                            }

                            
    $searchModel $this->_getSearchModel();

                                
    $constraints = array(
                                    
    'user' => array($userId),
                                    
    'content' => 'thread',
                                    
    'node'  => Ragtek_FW_Config::read('rit''node_id')
                                );

                                
    $searcher = new XenForo_Search_Searcher($searchModel);
                                
    $results $searcher->searchGeneral(''$constraints'date'1);

                            if (!
    $results) {
                                return 
    $this->getNoSearchResultsResponse($searcher);
                            }

                            
    $search $searchModel->insertSearch($results'user''', array('user_id' => $userId), 'date'false);

                            return 
    $this->responseRedirect(
                                
    XenForo_ControllerResponse_Redirect::SUCCESS,
                                
    XenForo_Link::buildPublicLink('search'$search),
                                
    ''
                            
    );
                        }
    This code, will return the newest thread, from an user and from an special node.

    I've placed this into the memebercontroller and linked on the member page ( http://localhost/xenforo/search/Introduce-Thread?user_id=1 )

    It just needs some little tweeks (e.g. => redirect direct to thread instead of search results,etc...)
     
  5. jgas

    jgas Active Member

    Hi ragtek,
    let's say that I want to display the latest 5 threads from a special node, and to display them in a custom tab of the profile .

    Do I need to modify the php above?
    What can I write on the html template code?

    Thanks, have a nice day!
     
  6. ragtek

    ragtek Guest

    You want to display on all users profile the latest 5 user threads (including perm check) from node X ?
    You wanna a add-on for 5$(because of my time:p ) for this?:D
     
  7. jgas

    jgas Active Member

    Sure! :D
    Is it possible to show also the post content?
    I want to display latest users "musical productions" so I thought it would be nice to display the post content with the embed players too.

    I can pay up to 15 dollars.

    Will it be a "standalone" addon or should I use the profile tab manager too?
     
  8. ragtek

    ragtek Guest

    Stand Alone:)
     
    jgas likes this.

Share This Page