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

Why isn't $threadId accessible in page_nav template?

Discussion in 'XenForo Development Discussions' started by king8084, Jul 22, 2016.

  1. king8084

    king8084 Active 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?
     
  2. Mike

    Mike XenForo Developer Staff Member

    Page-defined variables are just generally not available in that template.
     
  3. king8084

    king8084 Active Member

    what are my options then? how could i conditionally display the page numbers?
     
  4. Mike

    Mike XenForo Developer Staff Member

    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).
     
  5. king8084

    king8084 Active Member

    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> 
    
     
  6. king8084

    king8084 Active Member

    ^emphasis on the"<xen:if is="{$thread.thread_id} != '60154'">" line
     
  7. Snog

    Snog Well-Known Member

  8. king8084

    king8084 Active Member

    ...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
     
  9. king8084

    king8084 Active Member

    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.
     
  10. Snog

    Snog Well-Known Member

    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: Jul 22, 2016
    king8084 likes this.
  11. king8084

    king8084 Active Member

    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'}">
     
  12. king8084

    king8084 Active Member

    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.
     
  13. Snog

    Snog Well-Known Member

    Just keep in mind that the page_nav template is used anywhere paging happens.
     
  14. Snog

    Snog Well-Known Member

    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.
     
    king8084 likes this.

Share This Page