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

Display the forum the thread is in - Latest post

Discussion in 'XenForo Questions and Support' started by faeronsayn, Sep 24, 2011.

  1. faeronsayn

    faeronsayn Well-Known Member

    Hello guys,

    I am using ****** - Advanced Statistics...

    I think the development for this mod has stopped, or I just can't find anything on it.

    Anyways.. I am trying to add the forum the thread is located in, when its being displaying in the latest post block...

    http://localhostr.com/file/qDlyrSi/******%20problem.PNG

    as you can see, this only displays the thread name and the username what I want is for it to display the forum name the thread is located in as well, maybe beside the username, or something like that.

    Here is the code that I think corresponds to this section...

    Code:
    
    <div class="******AdvStats_SectionItem ******AdvStats_Thread">
    <div class="******AdvStats_SectionItemBlock ******AdvStats_SectionItemTitle ******AdvStats_ThreadTitle{xen:if '{$thread.isNew}', ' new'}">
    <a href="{xen:link '{xen:if '{$thread.isNew}', 'threads/unread', 'threads'}', {$thread}}">
    <xen:if is="@******AdvStats_ThreadTitleChars > 0">
    {xen:helper wordtrim, {$thread.title}, @******AdvStats_ThreadTitleChars}
    <xen:else />
    {$thread.title}
    </xen:if>
    </a>
    </div>
    <div class="******AdvStats_SectionItemBlock ******AdvStats_SectionItemInfo ******AdvStats_ThreadLastPoster">
    <xen:username user="$thread" rich="true" />
    
    </div>
    </div>
    
    I guess I am trying to add this there
    Code:
    <a href="{xen:link forums, $post}">{$post.node_title}</a>
    
    or something similar to display the node its located in, but it won't show it... when I put it in...
    If someone could tell me what phrase I should put in which section of this template, it would be great.
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    I will need to look at the addon to know if the forum title can be added. Do you have a link for that addon so I can install it myself?
     
  3. faeronsayn

    faeronsayn Well-Known Member

    You can find it right here...

    http://******.com/threads/******-advanced-forum-statistics.171/

    i'll attach the mod for you in this post, for your convenience.
     

    Attached Files:

  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Edit this template:

    Admin CP -> Appearance -> Templates -> ******AdvStats_threads_latest

    Add the red code:

    Code:
    <div class="******AdvStats_SectionItem ******AdvStats_Thread">
    	<div class="******AdvStats_SectionItemBlock ******AdvStats_SectionItemTitle ******AdvStats_ThreadTitle{xen:if '{$thread.isNew}', ' new'}">
    		<a href="{xen:link '{xen:if '{$thread.isNew}', 'threads/unread', 'threads'}', {$thread}}">
    			<xen:if is="@******AdvStats_ThreadTitleChars > 0">
    				{xen:helper wordtrim, {$thread.title}, @******AdvStats_ThreadTitleChars}
    			<xen:else />
    				{$thread.title}
    			</xen:if>
    		</a>
    		posted in <a href="{xen:link 'forums', {xen:array 'node_id={$thread.node_id}', 'title={$thread.forum_title}'}}">[{$thread.forum_title}]</a>
    	</div>
    	<div class="******AdvStats_SectionItemBlock ******AdvStats_SectionItemInfo ******AdvStats_ThreadLastPoster">
    		<xen:username user="$thread" rich="true" />
    	</div>
    </div>
    
    The result:

    Screen shot 2011-09-24 at 5.58.16 PM.png
     
    FredC and faeronsayn like this.
  5. faeronsayn

    faeronsayn Well-Known Member

    Thats great Jake thank you so much, is there any way to use this to filter out forums that you don't want on the latest posts block ?
     
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    You can't do that very well with a template mod. And I don't see any available input to restrict which node_ids are shown. You would have to modify the PHP code. It is best to contact the author about this.
     
  7. faeronsayn

    faeronsayn Well-Known Member

    ahh okay no problem, thank you for the help by the way.
     
  8. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Note that the addon does obey group permissions. If a user doesn't have access to a particular forum then it won't show threads from that forum.
     
  9. faeronsayn

    faeronsayn Well-Known Member

    Yes thats true, but we have a spam section / other sections ... where I wouldn't want the posts of those section to come up on the latest post block, for obvious reasons.
     
  10. daveb

    daveb Member

    i Couldn't find any way of requesting this addon for the block as the author does not seem to support / enhance it anymore, i decided to see if i could fudge a way of doing it ;)

    in library\******AdvStats I edited the Renderer.php file

    I can control which forums are displayed in the following section of code:-

    PHP:
            // finished important params
         
            // start looking for forums scope
            
    if (!empty($input['node_ids'])) {
                
    $nodeIds explode(','$input['node_ids']);
                if (
    $input['hash'] == self::calcHash($nodeIds)) {
                    
    // the hash is validated, use the list of forums now!
                    
    $conditions['******AdvStats_forum_ids'] = $nodeIds;
                }
            }
    So i tried the following code:-


    PHP:
    // finished important params
     
    // start looking for forums scope
    if (!empty($input['node_ids'])) {
    $nodeIds explode(','$input['node_ids']);
    for(
    $x=0;$x count($nodeIds); $x++) {
    if(
    $nodeIds[$x]=="15") {
    unset(
    $nodeIds[$x]);
    }
    where 15 is the id of the forum section i want to filter

    but if the unset line is in then i get an error displayed as follows:-

    An exception occurred: Undefined index: section_forum_id in public_html/library/******AdvStats/Renderer.php on line 188
    XenForo_Application::handlePhpError() in ******AdvStats/Renderer.php at line 188
    ******AdvStats_Renderer::renderSectionThreadPrepare()
    call_user_func_array() in ******AdvStats/Renderer.php at line 275
    ******AdvStats_Renderer::renderSection() in ******AdvStats/Renderer.php at line 387
    ******AdvStats_Renderer::_prepareSectionForWrapper() in ******AdvStats/Renderer.php at line 27
    ******AdvStats_Renderer::renderWrapper() in ******AdvStats/Listener.php at line 66
    ******AdvStats_Listener::template_post_render()
    call_user_func_array() in XenForo/CodeEvent.php at line 54
    XenForo_CodeEvent::fire() in XenForo/Template/Abstract.php at line 195
    XenForo_Template_Abstract->render() in XenForo/Template/Public.php at line 110
    XenForo_Template_Public->render() in XenForo/ViewRenderer/HtmlPublic.php at line 135
    XenForo_ViewRenderer_HtmlPublic->renderContainer() in XenForo/FrontController.php at line 565
    XenForo_FrontController->renderView() in XenForo/FrontController.php at line 156
    XenForo_FrontController->run() in public_html/index.php at line 13

    any help as I am new to Xenforo and so not sure what is causing this ?

    Lines 188+ of the code are as follows:-

    PHP:
            if (empty($conditions['******AdvStats_forum_ids']) AND $input['section_forum_id'] > 0) {
                
    // this is a custom section but hash was invalid or something like that
                // we will have to calculate the list of forums here
                
    $viewableNodes self::getSharedData(******AdvStats_Renderer::SHARED_DATA_VIEWABLE_NODES);
                
    $nodeIds self::getNodeIds($viewableNodes$input['section_forum_id']);
                
    $conditions['******AdvStats_forum_ids'] = $nodeIds;
            }
     
  11. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  12. daveb

    daveb Member

    tried that and if so i get the error of

    An unexpected error occurred. Please try again later.

    i changed line 188 to be

    if ((empty($conditions['******AdvStats_forum_ids'])) AND ($input['section_forum_id'] > 0) AND (isset($input['section_forum_id']))) {
     
  13. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    An unexpected database error? View the source code of the page to get the exact error message.

    More than likely this is a programming problem. Your modification probably broke it.
     
  14. daveb

    daveb Member

    the source of the page was the same :)

    anyways

    I have got further :) here is the code that actually works and allows me to filter out forum 15

    PHP:
            // start looking for forums scope
            
    if (!empty($input['node_ids'])) {
                
    $nodeIds explode(','$input['node_ids']);
                for(
    $x=0;$x count($nodeIds); $x++) {
                    if(
    $nodeIds[$x]=="15") {
                        unset(
    $nodeIds[$x]);
                    }
                }
    //            if ($input['hash'] == self::calcHash($nodeIds)) {
                    // the hash is validated, use the list of forums now!
                    
    $conditions['******AdvStats_forum_ids'] = $nodeIds;
                   
    //            }
            
    }
    So by commenting out the if ($input['hash'] == self::calcHash($nodeIds)) { loop it works fine, code is very complex so not sure what it is doing, permissions check perhaps ?

    I obviously don't want to leave this commented out, so is there anyone out there that can help me bypass the commenting :) ?
     
  15. faeronsayn

    faeronsayn Well-Known Member

    I have no idea, about php code lol, but I'd like to see this working :)
     
  16. faeronsayn

    faeronsayn Well-Known Member

    are we able to now filter out forums and such ?
     

Share This Page