1. 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?

Discussion in 'XenForo Questions and Support' started by James, Feb 18, 2011.

  1. James

    James Well-Known Member

    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.
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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

    	<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:edithint template="attached_files" />
    Regarding xen:container, see Kier's post here:


    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:

    James likes this.

Share This Page