multiple layouts with one template

Forum closed, please submit your tips and tricks to: http://docs.joomla.org/Category:Tips_and_tricks
Locked
webstar
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Feb 21, 2007 9:58 am

multiple layouts with one template

Post by webstar » Wed Mar 19, 2008 10:24 am

I'm not sure if this has been posted before but here goes.
I found that it was a bit of a pain to code and keep track of multiple templates so ive been searching for a way to do this in Joomla 1.5. I stumbled upon this solution thru a few different threads.

basically im testing for the existence of say Fireboard and delivering a unique layout for that & testing for myblog then delivering a different layout for myblog and if none of these exist then just churn out the standard content block.

you should be able to swap these values out for any component

Code: Select all

<?php if (JRequest::getVar('option') == 'com_fireboard' ) {?> <!--code to detect Fireboard is loaded-->
              
              <div class="MainCol">
              	 <jdoc:include type="component" />
               </div>
               <div class="RightCol">
             		 <jdoc:include type="modules" name="RightCol" style="none" />
               </div>
              
              <?php  }  elseif  (JRequest::getVar('option') == 'com_myblog') {?> <!--code to detect Blog is loaded-->
     <div class="LeftCol">
             		 <jdoc:include type="modules" name="LeftCol" style="none" />
               </div>
               <div class="MainCol">
              	 <jdoc:include type="component" />
               </div>
               
              <?php  }  else {?>
              <jdoc:include type="component" />
			  
			  <?php   } ?>
Anyway I hope this helps someone
Thanks
Derek

User avatar
trichnosis
Joomla! Explorer
Joomla! Explorer
Posts: 315
Joined: Wed May 17, 2006 4:15 pm

Re: multiple layouts with one template

Post by trichnosis » Tue Apr 08, 2008 6:54 am

it's the most intresting tip i have read on joomla forum

webstar
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Feb 21, 2007 9:58 am

Re: multiple layouts with one template

Post by webstar » Tue Apr 08, 2008 8:57 am

ive started this method on many sites now. you can basically cater for just about any combination of components and associated pages. just watch the url bar to see what component, pages or item ids are being loadedand then you can create a custom laout just for that particular scenario.

cheers

derek

otuyelu
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Fri Apr 18, 2008 6:41 pm

Re: multiple layouts with one template

Post by otuyelu » Tue May 06, 2008 8:51 am

This makes it so much more efficient, than having to create separate template for individual pages with different layout requirements. Thanks Webstar!


Locked

Return to “Submit Your Suggested Tips & Tricks to Docs.joomla.org now please.”