Same template but only showing content blocks on some pages?

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
pwg
Forum Members
Forum Members
Posts: 191
Joined: Tue Aug 01, 2006 1:48 am

Same template but only showing content blocks on some pages?

Post 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
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Contact:

Re: Same template but only showing content blocks on some pa

Post 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
pwg
Forum Members
Forum Members
Posts: 191
Joined: Tue Aug 01, 2006 1:48 am

Re: Same template but only showing content blocks on some pa

Post 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.
User avatar
rotezecke
Power Poster
Power Poster
Posts: 411
Joined: Fri Apr 18, 2008 9:34 pm

Re: Same template but only showing content blocks on some pa

Post by rotezecke »

you may want to look at template inheritance if the only difference between templates is an extra content block.
pwg
Forum Members
Forum Members
Posts: 191
Joined: Tue Aug 01, 2006 1:48 am

Re: Same template but only showing content blocks on some pa

Post 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
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Same template but only showing content blocks on some pa

Post 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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
pwg
Forum Members
Forum Members
Posts: 191
Joined: Tue Aug 01, 2006 1:48 am

Re: Same template but only showing content blocks on some pa

Post by pwg »

Great, thanks a lot calguy.

Cheers,
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Same template but only showing content blocks on some pa

Post 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 ;)...
Post Reply

Return to “The Lounge”