• 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

faeronsayn

Well-known member
#1
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.
 

Jake Bunce

XenForo moderator
Staff member
#2
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?
 

Jake Bunce

XenForo moderator
Staff member
#4
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
 

Jake Bunce

XenForo moderator
Staff member
#6
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 ?
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.
 

Jake Bunce

XenForo moderator
Staff member
#8
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.
 

faeronsayn

Well-known member
#9
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.
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
is there any way to use this to filter out forums that you don't want on the latest posts block ?
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;
        }
 
#12
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']))) {
 

Jake Bunce

XenForo moderator
Staff member
#13
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
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 :) ?