XF 1.5 Passing variables to templates?

Helixion

Member
Hello, I'm currently using xenporta, and I want to pass a variable to the page_container template.

Currently I'm using this snippet of code:
Code:
<xen:if is="{$contentTemplate} == 'EWRporta2_ArticleView' || {$contentTemplate} == 'thread_view'">
                <div class="userAvatar">
                   <xen:avatar user="$posts.{$thread.first_post_id}" size="s" />
           </div>
    </xen:if>

and with css, it would position the avatar of the first poster (which in this case is author) to the left of the topic title. Unfortunately $posts doesn't seem accessible to page_container.

So my question is how would I make it so page_container can access $posts?
 
You can't use variables from content template inside container without passing them to container. Use something like this in content template:
Code:
<xen:container var="$first_post_id">{$thread.first_post_id}</xen:container>
then you can use variable {$first_post_id} in page_container.
 
You can't use variables from content template inside container without passing them to container. Use something like this in content template:
Code:
<xen:container var="$first_post_id">{$thread.first_post_id}</xen:container>
then you can use variable {$first_post_id} in page_container.

hey thanks for the help, which content template should I pass the variable from however? I used EW2porta_ArticleView / List but that didn't seem to do anything? Where do the $posts / $thread variables come from?
 
From wherever those variables exist. You posted that code, so I assumed you knew what those variables were and simply had issues accessing them. Don't use code I posted literally, use it as example on how to modify your code.

I suggest creating that whole div inside content template, then assigning it to container variable. Then in container template simply use {xen:raw $whatever} to display that code.
 
Back
Top Bottom