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

thread_view conditional Template Modification

Discussion in 'XenForo Development Discussions' started by MattW, Nov 4, 2013.

  1. MattW

    MattW Well-Known Member

    I'm trying to change what is being displayed in thread_view using Template Modification

    This is my template modification

    Code:
    <xen:if is="{$contentTemplate} == 'thread_view'">
    <div id="slidingDiv">
    Matt Test 1
    </div>
    <xen:else />
    $0
    </xen:if>
    However, it's not displaying what I want in thread_view

    I've checked the source looking at the content div

    Code:
    <div id="content" class="thread_view">
    But it's displaying the contents of the else statement.

    Any idea why this isn't working as expected?
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    Which template are you adding that code to?
     
  3. MattW

    MattW Well-Known Member

    It's a template which is included inside thread_view. The actual template is called similar_threads which is inserted with the Listener looking for the hook thread_view_qr_after
     
  4. Chris D

    Chris D XenForo Developer Staff Member

    Why do you need to check if the $contentTemplate is thread_view if the code is going into the thread_view template?

    Also, why use a Listener and Hook if you can just use the template modifications system to add the content to the template? :)
     
  5. MattW

    MattW Well-Known Member

  6. Chris D

    Chris D XenForo Developer Staff Member

    Ah ok. This will work:
    Code:
    <xen:if is="{$thread.thread_id}">
        <div id="slidingDiv">
            Matt Test 1
        </div>
    <xen:else />
        $0
    </xen:if>
    {$thread.thread_id} will only be set in thread_view, it won't be set in thread_create :)
     
    MattW likes this.
  7. MattW

    MattW Well-Known Member

    Perfect, thanks again Chris
     

Share This Page