What is more efficient? Template include or hard coded into template?

steven s

Well-known member
For instance.
We can either create a template and add to say, PAGE_CONTAINER using <xen:include template="template_name" /> or
add directly to PAGE_CONTAINER.

On one hand it's less to edit when reverting templates when using include template.
On the other hand, does it take longer to render the page using the include?

6 of 1, 1/2 dozen of another?
Is one better coding practice over the other?
Whatever floats your boat?
 
It makes no difference whatsoever - all template includes are resolved at save time, not run time.
Good to know.
I always use an include as it keeps the main templates tidier and it just seems like better practice.

In the same way that I don't do inline styling but use separate stylesheets.
Tidier is good.

Regarding inline styling. You would not use <div style="text-align: center;"></div> but rather place the CSS in EXTRA.css?
Any reason, or just tidier also?
 
Regarding inline styling. You would not use <div style="text-align: center;"></div> but rather place the CSS in EXTRA.css?
Any reason, or just tidier also?
Just to keep it tidy and also make it easy to locate/change in the future.

I give each entry in EXTRA.css a short description so I know what it's for.
For example:
Code:
/* Move search box */
#QuickSearch {
right: 10px;
}

/* Make URL links in posts bold */
.ugc a {
font-weight: bold;
}

/* Change colour of the primary button */
.button.primary {
background-color: @secondaryLighter;
}
 
Yes, but if you put all you're own elements into the extra.css, which aren't needed global, it will blow it up unnecessary;)
 
For instance.
We can either create a template and add to say, PAGE_CONTAINER using <xen:include template="template_name" /> or
add directly to PAGE_CONTAINER.

On one hand it's less to edit when reverting templates when using include template.
On the other hand, does it take longer to render the page using the include?

6 of 1, 1/2 dozen of another?
Is one better coding practice over the other?
Whatever floats your boat?
Regarding inline styling. You would not use <div style="text-align: center;"></div> but rather place the CSS in EXTRA.css?
Any reason, or just tidier also?
OK, so if the CSS is used say only in the sidebar it makes more sense to code the css within the template.
I don't know if my logic is correct here but this is what I have been doing...

adding my css rules to a new template as to be able to edit that specific entity in the admin panel by isolating that specific set of styling rules in the way of as brogan put it 'tidiness'.

Then if the case at hand is CSS I would do a <xen:include template="mynew.css" />in the xenforo.css template to call it all together. It works for me as sometimes I use DW but for the most part I'm either editing templates directly in the admin panel or over ftp, editing documents which for me opens up WIN notepad.exe (HA shut off text wrap) so personally speaking... easily finding modifications I have made is essential as I am NOT a coder.

I suppose I could try using the extra.css as (unless i'm to stand corrected) it gets included on every page.

Question: would this work...

make new template { newcss1.css} --- add my code
throw a --> <xen:include template="newcss1.css" /> in the extra.css template

...to include custom styling on every page?
 
Adding custom_template.css to support custom_tempate and then referencing it with <xen:require css="custom_template.css" /> is precisely how the system is intended to be used.
 
Adding custom_template.css to support custom_tempate and then referencing it with <xen:require css="custom_template.css" /> is precisely how the system is intended to be used.
Kier could you possibly re-word "to support custom_template" I'm just a little out of it right now and I think your saying when I make a custom template "this_template" I would make a corresponding "this_template.css" and do the xen:require css in the "this_template"
 
The template names are not related at all.
You just reference each one using either: <xen:include template="" /> or <xen:require css="" />

So in your custom template you would add <xen:require css="" />

In an existing template you would add <xen:include template="" />
 
Ok now I have a question that I can't derive an answer from.

I redid my xxmP BBcode which requires template edits and using the exact same setup as before on a clean installation sans the edit of the xen:include to xen:require for the css additions and it broke the code...by replacing it back to :include the code instantly worked again.

what am I doing wrong... lol
 
Top Bottom