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

Using Variables from Other Templates?

James

Well-known member
#1
I swear there was a way to use variables from other templates using xen:container and xen:set... or have I just been dreaming?

For example, if I wanted to use the $message array in the thread_view template.
 

Jake Bunce

XenForo moderator
Staff member
#2
I swear there was a way to use variables from other templates using xen:container and xen:set... or have I just been dreaming?

For example, if I wanted to use the $message array in the thread_view template.
In the thread_view template you can already access the $posts array which contains each individual $post. Here is code from the thread_view template which loops through all of the posts:

Admin CP -> Appearance -> Templates -> thread_view

Code:
	<ol class="messageList" id="messageList">
		<xen:foreach loop="$posts" value="$post">
			<xen:if is="{$post.message_state} == 'deleted'">
				<xen:include template="post_deleted_placeholder" />
			<xen:else />
				<xen:include template="post" />
			</xen:if>
		</xen:foreach>
		<xen:edithint template="attached_files" />
	</ol>
Regarding xen:container, see Kier's post here:

http://xenforo.com/community/thread...ion-this_script-index.6664/page-2#post-156780

xen:set just allows you to assign values to variables within the templates. The second video in this thread has a good demo of using xen:set with template includes:

http://xenforo.com/community/threads/editing-templates-and-defining-a-callback-for-pages.7226/