Do conditionals really put a tax on performance when you have several in a template?
I’m building a new site for a client who uses a shared hosting plan from Verio. The pages are sluggish. Never had performance issues with EE before, but my setups are generally pretty simple and I’m usually working on dedicated servers.
The EE setup for this site is a little different. I wanted to reduce the number of templates so I’m using lots of conditionals in one template to determine things like the active section, and what other queries need to be run on a page-by-page basis. Sections, btw, are simply categories.
Basically, every page on the website starts with this:
{assign_variable:my_weblog="company"}
{if segment_1== "company"}
{assign_variable:my_category="1"}
{assign_variable:my_template_group="company"}
{/if}
{if segment_1 =="capabilities"}
{assign_variable:my_category="2"}
{assign_variable:my_template_group="capabilities"}
{/if}
{if segment_1 =="solutions"}
{assign_variable:my_category="3"}
{assign_variable:my_template_group="solutions"}{/if}
{if segment_1 =="experience"}
{assign_variable:my_category="4"}
{assign_variable:my_template_group="experience"}
{/if}
if segment_1 == "news"}
{assign_variable:my_category="10"}
{assign_variable:my_template_group="news"}
{/if}
{if segment_1 =="connect"}
{assign_variable:my_category="5"}
{assign_variable:my_template_group="connect"}
{/if}Then I have other conditionals in the body of the page to display content in certain fields, if it exists.
{if graphic !=""}{graphic}{/if}
{if attachments !=""}<h4>Downloads</h4><p>{/if}<br />
{if attachments !=""}{attachments}{/if}<br />
{exp:allow_eecode}{if extended !=""}{extended}{/if}{/exp:allow_eecode}<br />
{/exp:weblog:entries}I like the setup. For the most part, all my HTML and EE code is one template, which is rather nice. I’m just not sure if these conditionals make it an ill-conceived setup from a performance standpoint ... or maybe it’s a combination of the setup and the fact that I’m on a $20 shared hosting plan.
Any event, the site is here, http://www.anthemcorp.com/ee/ . No real content, yet, but you can flip through and get sense of the responsiveness.