How to use the $thread in the 'navigation' template

tonnyz

Member
Hello, sorry if I post it in a wrong forum

I'm trying to move my 'reply to thread' button into my navigation template

I moved the code beneath from my 'thread_view' template to my 'navigation' template

Code:
<xen:if is="{$canReply}">
    <xen:comment><xen:topctrl>
        <a href="{xen:link 'threads/reply', $thread}" class="callToAction"><span>{xen:phrase reply_to_thread}</span></a>
    </xen:topctrl></xen:comment>
</xen:if>

<xen:if is="{$canReply}">
    <xen:topctrl>
        <a href="{xen:link 'threads/reply', $thread}" class="callToAction"><span>{xen:phrase reply_to_thread}</span></a>
    </xen:topctrl>

<xen:elseif is="{$visitor.user_id}" />
    <xen:comment>
    <xen:topctrl>
    <span class="element">({xen:phrase no_permission_to_reply})</span>
    </xen:topctrl>   
    </xen:comment>
<xen:else />
    <xen:topctrl>
        <label for="LoginControl"><a href="{xen:link login}" class="callToAction"><span>{xen:phrase reply_to_thread}</span></a></label>
    </xen:topctrl>
</xen:if>

In the 'thread_view' template it normally links the 'reply to thread' button to a link ended with
".../threads/my-forum-name.3/reply"

but when I move the code to the 'navigation' template, it gives me a link ended with
".../threads/reply"

as seen above, the thread name's omitted as though the $thread in the script have no value when it's used in the 'navigation' template

Do you have any idea for this ? Thanks before.
 
The $thread variable isn't available in that template.

It would require custom development/an add-on.
 
You can pass variables to the container by using

Code:
<xen:container var="$variable">value of variable</xen:container>

So you can edit your thread_view template. Unfortunetely you can't pass arrays like this so you'd have to pass every variable individually, something like this:

Code:
<xen:container var="$thread.thread_id">{$thread.thread_id}</xen:container>

That should provide you a decent start.
 
The $thread variable isn't available in that template.

It would require custom development/an add-on.

is it something like what Mr. Hood said, or is it a different thing ?
v
v
You can pass variables to the container by using

Code:
<xen:container var="$variable">value of variable</xen:container>

So you can edit your thread_view template. Unfortunetely you can't pass arrays like this so you'd have to pass every variable individually, something like this:

Code:
<xen:container var="$thread.thread_id">{$thread.thread_id}</xen:container>

That should provide you a decent start.

sorry, sir, I'm not a coder and not familiar with XF either :(

Is it a complicated task for accomplishing this ? Could you please kindly post here where and how I insert it to my 'navigation' template ?

I've tried it like this with no good result #shame on me :cry:
v
v
Code:
<xen:container var="$thread.thread_id">{$thread.thread_id}</xen:container>
<xen:if is="{$canReply}">
    <xen:comment><xen:topctrl>
        <a href="{xen:link 'threads/reply', $thread}" class="callToAction"><span>{xen:phrase reply_to_thread}</span></a>
    </xen:topctrl></xen:comment>
</xen:if>

<xen:if is="{$canReply}">
    <xen:topctrl>
        <a href="{xen:link 'threads/reply', $thread}" class="callToAction"><span>{xen:phrase reply_to_thread}</span></a>
    </xen:topctrl>

<xen:elseif is="{$visitor.user_id}" />
    <xen:comment>
    <xen:topctrl>
    <span class="element">({xen:phrase no_permission_to_reply})</span>
    </xen:topctrl>
    </xen:comment>
<xen:else />
    <xen:topctrl>
        <label for="LoginControl"><a href="{xen:link login}" class="callToAction"><span>{xen:phrase reply_to_thread}</span></a></label>
    </xen:topctrl>
</xen:if>
 
Top Bottom