Why isn't $threadId accessible in page_nav template?

king8084

Well-known member
I'm trying to limit the way that the page navigation behaves, specific to a single thread (a Link Forum, pointing to a single thread).

How can I get the thread_id (or $threadId) accessible in page_nav? I've attempted to add the following to page_nav, but no luck:
<xen:container var="$threadId">{$post.thread_id}</xen:container>


thoughts?
 
Page-defined variables are just generally not available in that template.
 
I'm not clear on what you're trying to do, but if you really need thread-related data to be available within the page nav, you're going to need custom development to pass that data in (essentially reimplementing the page nav system).
 
I'm not clear on what you're trying to do, but if you really need thread-related data to be available within the page nav, you're going to need custom development to pass that data in (essentially reimplementing the page nav system).
specifically, i'm trying to do the following:
Code:
<xen:edithint template="page_nav.css" />

<xen:if is="{$pageTotal} > 1">
<div class="PageNav{xen:if '{$maxDigits} > 4', ' pn{$maxDigits}'}"
    data-page="{$currentPage}"
    data-range="{$range}"
    data-start="{$startPage}"
    data-end="{$endPage}"
    data-last="{$pageTotal}"
    data-sentinel="{$pageNumberSentinel}"
    data-baseurl="{xen:link $linkType, $linkData, '_params={$linkParams}', 'page={$pageNumberSentinel}'}">
  
    <nav>

    <xen:if is="{$thread.thread_id} != '60154'">
 
       ***default 'stuff' here***
     
    <xen:else />
 
       ***the 'stuff' unique to this thread/forum here***
    </nav>
 
...if there's truly no way to identify the thread id from within page_nav, then can you point me to where page_nav is called from? i can't locate it, but i could essentially do a conditional from wherever it's being summoned from and then recreate a new/copy of page_nav template to be called for my specific thread. @Mike
 
If this is in relation to this thread.. https://xenforo.com/community/threa...osts-on-prev-page-are-w-in-x-days-ago.118735/

What you want to do would require a complete add-on that changes what posts are displayed and sends the proper paging info. That's not something that can be done via the template system.
it's in relation to that, but this here is much simpler alternative approach that I thought would be much more feasible to accomplish in the template system. i really just need to be able to identify the thread id in page_nav (or alternatively, identify the thread id where page_nav gets called [i'm not sure where that's at?]), and then everything from there would be smooth.
 
Well, I'm not sure how you're going to change the page count, etc. But the thread_id is available in the $linkData in the page_nav template. {$linkData.thread_id}

But the problem you might run into is the page_nav template is used everywhere. Not just for thread viewing.
 
Last edited:
Well, I'm not sure how you're going to change the page count, etc. But the thread_id is available in the $linkData in the page_nav template. {$linkData.thread_id}

But the problem you might run into is the page_nav template is used everywhere. Not just for thread viewing.
yess!!! that's all I was looking for -- you're a life saver.

as for how i'm going to adjust the rest, I'm planning to simply have a "load previous chat data" display if the $prevPage is greater than the $pageTotal - 6...essentially, rather than implementing a 48 hour limit, I'll be limiting a 100 post limit (5 pages @ 20 posts a page). somethign along these lines:

<xen:if is="{$prevPage} && {$prevPage} > {xen:calc '{$pageTotal} - 6'}">
 
quick follow-up question on that, @Snog -- how would I have known that $linkData housed that data from page_nav? Yes, i now see it used throughout the template, but if it wasn't used by the code by default, then how could I identify if it could be used?

I've used the <xen:helper dump> quite a bit, but it's always been a bit of guess and check to see which vars are available at which templates. some are obvious based on template name, but the rest (like page_nav), it's unclear.
 
quick follow-up question on that, @Snog -- how would I have known that $linkData housed that data from page_nav? Yes, i now see it used throughout the template, but if it wasn't used by the code by default, then how could I identify if it could be used?

I've used the <xen:helper dump> quite a bit, but it's always been a bit of guess and check to see which vars are available at which templates. some are obvious based on template name, but the rest (like page_nav), it's unclear.
Experience I guess. ;)

But seriously, knowing where the page_nav template is called and what params are in the page_nav template, it's not hard to figure out.

The page_nav template is called by this (or something similar to it) in just about any template it's used in...
Code:
<xen:pagenav link="threads" linkdata="{$thread}"
   page="{$page}" perpage="{$postsPerPage}" total="{$totalPosts}"
   unreadlink="{$unreadLink}" />

These items all change depending on the page it's being used on:
link
linkdata
page
perpage
total

The unreadlink is not included in all uses.
 
Top Bottom