Page 1 of 1
Same template but only showing content blocks on some pages?
Posted: Wed Nov 05, 2014 11:52 pm
by pwg
Hi,
In order to just show content on certain pages, I have for example"
{if $page_alias eq "home"}
{$second_content}
{/if}
in a template.
I use this as not all pages need the second content block, but the problem I have is content editors can see this second content block on every page that uses the template.
Is there a better way to do this?
I could just add a new template for each section, but wonder about page loading speed? Is there much of an effect with extras templates?
Thanks for any help, it is much appreciated.
Cheers,
Paul
Re: Same template but only showing content blocks on some pa
Posted: Wed Nov 05, 2014 11:56 pm
by paulbaker
I very much doubt you would be able to measure page loading speed difference.
But regardless of that, how about using global content blocks and show (or not) with similar if then functionality?
http://docs.cmsmadesimple.org/content/g ... ent-blocks
Re: Same template but only showing content blocks on some pa
Posted: Thu Nov 06, 2014 12:03 am
by pwg
Thanks Paul, but on this particular site, I think from past experience the client would just become confused with the GCB's - it seems easier to have them access the page via the admin and edit there.
May be easier just to create new templates, its a simple enough task.
Thanks for the reply.
Re: Same template but only showing content blocks on some pa
Posted: Thu Nov 06, 2014 5:49 pm
by rotezecke
you may want to look at
template inheritance if the only difference between templates is an extra content block.
Re: Same template but only showing content blocks on some pa
Posted: Thu Nov 06, 2014 11:46 pm
by pwg
Thanks again, that looks template inheritance looks like an ideal solution.
Again, possibly an odd question but do you think there would be a page loading speed difference using template inheritance over 2 different templates?
Cheers,
Paul
Re: Same template but only showing content blocks on some pa
Posted: Fri Nov 07, 2014 12:12 am
by calguy1000
pwg wrote:Again, possibly an odd question but do you think there would be a page loading speed difference using template inheritance over 2 different templates?
Smarty templates are compiled into PHP code only when the system thinks that the templates have been modified, or no compiled template exists. Therefore if your database, and file system times are in sync the template will only be compiled IF it has changed (or the compiled file does not exist). Therefore there should be no significant performance difference.
Re: Same template but only showing content blocks on some pa
Posted: Fri Nov 07, 2014 3:58 am
by pwg
Great, thanks a lot calguy.
Cheers,
Re: Same template but only showing content blocks on some pa
Posted: Fri Nov 07, 2014 4:22 am
by Dr.CSS
You could give it a tab= parameter, that will put it at the top set of tabs, Main, Options, Preview, out of line of site out of mind

...