XF template system question

Ryan Kent

Well-known member
I really wish there was a XenTemplates 101 user guide so I could read it and learn. Since there is not, I will do my best to learn it the hard way.

My initial question concerns "content" code. Using the below code as an example, my questions are:

- where does the "hascontent" portion of xen:if hascontent="true" come from? Is it a variable?
- where does the <xen:contentcheck> come from?

I basically seek to understand this code and how it works. I am totally lost on these seemingly simple points.

        <xen:if hascontent="true">
            <xen:foreach loop="$StatusUpdates" value="$update">
                    <xen:avatar user="$update" size="s" img="true" />
                    <a href="{xen:link members, $update}" class="username" style="display: inline;">{xen:helper richUserName, $update}</a>
                    <span class="userTitle">{$update.message} (<xen:datetime time="$update.post_date" />)</span>


Well-known member
I assume you know their function? The contents of the <xen:if hascontent="true"> will only be displayed if there is content to display, and the <xen:contentcheck> goes hand-in-hand with the hascontent attribute.

Where they come from I can't tell you as my test install isn't up. Try looking in the Compiler folder.

Ryan Kent

Well-known member
I appreciate the reply. I have developed in VBA and MS SQL extensively, but I learned absolutely nothing from your reply.

The contents of the <xen:if hascontent="true"> will only be displayed if there is content to display
How exactly is the determination made as to whether or not there is content?

<xen:contentcheck> goes hand-in-hand with the hascontent attribute.
Where is this attribute's value set?

Try looking in the Compiler folder.
What is a compiler folder? Where is it located?

Again, I have never used a template system before XF. I need a basic user guide. Let's assume I am an intelligent life form with general coding experience, but have never used a template system before. I need to start from that point, and go from there. Your reply seems to be for someone who has worked with this system already and has knowledge of these things.


Well-known member
Hi Oracle,

You are asking how it is compiled? I see. The compiler folder is located at library/XenForo/Template. I'll have a look through them, but I'm not entirely sure.


Well-known member
In library/XenForo/Template/Compiler/Tag you'll notice a file called If.php. This controls the <xen:if> conditionals, and inside it you'll see some code. This controls the <xen:if> attributes, which I now realise are is, hascontent, segments, line.

Ryan Kent

Well-known member
I realize you are trying to assist me James, and I appreciate your efforts. At this point I am absolutely not the slightest bit closer to answering my original questions. The thread is just getting bigger. If perhaps someone else could give a shot at responding, that would probably be best.


Well-known member
From my understandind, it checks in this order.

<xen: contentcheck> is the one deciding if hascontent is true or not. In this case, we specified xen: avatar ,xen:link, and a few others.

So if 1 of the specified value exists (avatar, link, etc), contentcheck has content, so hascontent=true.

I found a similar thread, hope they're good examples.



Well-known member
Maybe I was unsure of your question. I thought you wanted to know how it was compiled - my bad.

Ryan Kent

Well-known member
Thank you Panupat! Those links were absolutely perfect. I am clear now.

James, I recognize you are very knowledgeable. In this instance you were not able to convey your knowledge in a way that I understood it. Probably my fault. No worries, and again I truly appreciate the effort.