XF 1.3 What is the difference between xen:container and xen:set?

HeadHodge

Active member
Hi,

I'm still unable to figure out what the difference between these two command are.

Here is a line from the Thread_Edit template:
<xen:container var="$searchBar.thread"><xen:include template="search_bar_thread_only" /></xen:container>

I'm not understanding what the difference is between the "container" command and the "set" command. They both look like they create a temp variable.

Also is there anywhere a "complete" list of xen syntax out there?

All I could find is:
http://xenforo.com/help/html-templates/


If there is a syntax reference guide, I'm not able to find it.

Thanks in advance
 
Guess No One Knows???

I tried both to see if I figure it out myself. Using the xen:set using the number 5. It sets my variable to 5 (like I would expect). Using the xen:container using the number 5. It set the variable to null.

So I still can't figure out what is or when to use the xen:container variable. :(
 
<xen:container> sets the value in the container template.
Well that's for that at least.

Now I just have to figure out what a container template is compared to the templates I create to include in other templates (i.e. Thread_Create). Is Thread_Create considered a "container template" ?
 
The container scope is the PAGE_CONTAINER template and all templates included by it.

XenForo has the container template (PAGE_CONTAINER) and the content template (different for each page). The content template is rendered first. You can use xen:container in the content template to define variables for use in the container which is rendered later.
 
  • Like
Reactions: KiF
The container scope is the PAGE_CONTAINER template and all templates included by it.

XenForo has the container template (PAGE_CONTAINER) and the content template (different for each page). The content template is rendered first. You can use xen:container in the content template to define variables for use in the container which is rendered later.
Oh yeah, now that makes sense. Thanks!!!

My interpretation of what you said is that:

The xen:set is a local like variable with the scope limited to the template it's located in. While, the xen:container is a global like variable whose scope is not only the template it's located in but also accessible by it's ancestor templates.

I'm pretty sure my definition is not totally true though, because it doesn't explain why when I set a xen:container to 5 in my custom template(which is included in the Thread_Create template), it displays null in my template (with xen:helper dump).

But I feel like I'm making some progress now!!!

(Edit: I re-read your post and you specify "and all templates included in it". If I took that literally to mean just those and only those, then that would explain why I get nulls. Because my template is included in another template that is included in the page template. Mine isn't included in the page template. So it doesn't qualify for use by xen:container, while Thread_Create does, because it's a "direct" descendant of the page container. Just a theory, but does that sound correct?)
 
Last edited:
xen:container is used in the content template to set variables in the container. xen:set is used in any template to set variables in the same template.
ok thanks for your reply. I think I understand.

So does that mean that if I use xen:container in my custom template (i.e. $myVar), it will be available in the page container even though it shows it's value as null in my template?

I "really" appreciate you responding to my questions, this is really helping me use my template in more efficient ways.
 
ok thanks for your reply. I think I understand.

So does that mean that if I use xen:container in my custom template (i.e. $myVar), it will be available in the page container even though it shows it's value as null in my template?

I "really" appreciate you responding to my questions, this is really helping me use my template in more efficient ways.

Yes.
 
Back
Top Bottom