More often than not when using multiple templates on a site the templates are variations of one template that begins with cloning the primary template to a dir of another name.
EG:
1. /templates/MyTemplateName
2. /templates/MyTemplateName_forum
3. /templates/MyTemplateName_gallery
In this case there are 2 options:
1. Clone the whole template dir tree
This gives a completely independant template but all paths must be altered in the template index.php to suit the new template name.
2. Clone only index.php and the /css
This allows all includes to still point to the primary template reducing redundancy while allowing the 2 most important files to be unique.
I do the above when I want the possibility of 3 cols everywhere except the forum and/or the gallery. Since the needs of a forum are about the same as a gallery, both need the full width with 1 main column, creating /templates/MyTemplateName_special is adequate for both.
A side note: forums do not work very well when assigned to a different template and require the "Default" = MyTemplateName_special and the primary site template be set to "Assigned" = MyTemplateName. The reason it needs to be done this way is each forum post is unique and cannot be part of the Mambo menu structure so it will be loaded by the Default template. This is a work-around and will require that every new menu item be assigned to the primary template MyTemplateName as opposed to the default template MyTemplateName_special and will be necessary until Mambo allows assigning a template to a section or category rather than only to a menu item.
FAQ: Assigning templates to forums or galleries
Moderator: mcsmom
FAQ: Assigning templates to forums or galleries
Last edited by kenmcd on Sun Sep 04, 2005 9:59 am, edited 1 time in total.
Freedom is not free!
It is however Open Source.
It is however Open Source.
-
- Joomla! Apprentice
- Posts: 25
- Joined: Wed Aug 17, 2005 11:22 pm
- Location: Southern California
- Contact:
Re: Assigning templates to forums or galleries
This multi templae option can also be done with a segmented singular index.php in the template.
I use a simple switch statement to decide on either a 3 column(default/normal) display format, or a two or single column (depends on the site). This way there is no need to maintain two index.php files only one. All the code for the mid-column based part of my template is duplicated according to number of columns within that switch statement. The header and footer code are executed before, and after the switch statement.
I create mutiple columner display code, which is switched based on the "option=" portion of the requesting url.
For example, at roadstarclinic.com, whenever "$option == 'com_simpleboard'" the template uses a two column format, and moves the right column to the left side of the screen.
I add and remove component options as needed within the two sections of that switch statement. Most of my sites have this type of switch statement in thier templates.
GRAM
I use a simple switch statement to decide on either a 3 column(default/normal) display format, or a two or single column (depends on the site). This way there is no need to maintain two index.php files only one. All the code for the mid-column based part of my template is duplicated according to number of columns within that switch statement. The header and footer code are executed before, and after the switch statement.
I create mutiple columner display code, which is switched based on the "option=" portion of the requesting url.
For example, at roadstarclinic.com, whenever "$option == 'com_simpleboard'" the template uses a two column format, and moves the right column to the left side of the screen.
I add and remove component options as needed within the two sections of that switch statement. Most of my sites have this type of switch statement in thier templates.
GRAM
GRAM
http://coders.mlshomequest.com/ < -- Developer of samSiteMap component
http://coders.mlshomequest.com/ < -- Developer of samSiteMap component
Re: Assigning templates to forums or galleries
Using a variable is probably much better than my low-tech method. Perhaps an example of the code and how to implement it would be a useful addition to this thread.
Cheers
Cheers
Freedom is not free!
It is however Open Source.
It is however Open Source.
-
- Joomla! Apprentice
- Posts: 25
- Joined: Wed Aug 17, 2005 11:22 pm
- Location: Southern California
- Contact:
Re: Assigning templates to forums or galleries
per camos request:
I use two methodologies, each dependent upon the site it is deployed on. On some sites, in particular where a lot of custom development is taking place, I use the method of setting a variable with the code used to display a page. This could be adapted via mosaddphp or a custom mambot to also be used in moscontent. Since the execution of the component code takes place before the template is called, setting this varible within the component code itself works very well.
The objective is to set a global variable that the template switches on. If the global variable does not exist, the default portion of the switch statement is used. On the example below (div based template) the left column is eliminated and the component (or mainbody rendering) has a full width single column.
This is on a Real Estate website, and is used for a few selective screens where full width is required for the content. Site is http://mlshomequest.com and this global variable is used to display the initial search screen for the "MLS property search" in the horizontal menu at the top. Global variable is $sw.
Index.php, after header and pathway code, preceeding footer code. The code is messy, as it has evolved along with the needs on the website and many areas have been commented out:
The second method is switching based on $option variable, which allows me to effect the same change when needed for specific components. Site is http://roadstarclinic.com, and switch takes place for the com_simpleboard component option in the url, same disclaimer as above as the code has been evolving along with the site. This code creates the middle section in the window and footers, and based on switch evaluation either creates a three colum layout, or a two colum layout. Template is table based:
This could be done much more efficiently, but it does work. I worried about the length of the file initially, but as php ignores contents of a switch statement that it does not execute, the longer file added no significant time to a page load.
FWIW.... I clearly am NOT a template designer ::) , these examples are presented as another way to effect template outcome, not as expamles of ideal template coding.
GRAM
I use two methodologies, each dependent upon the site it is deployed on. On some sites, in particular where a lot of custom development is taking place, I use the method of setting a variable with the code used to display a page. This could be adapted via mosaddphp or a custom mambot to also be used in moscontent. Since the execution of the component code takes place before the template is called, setting this varible within the component code itself works very well.
The objective is to set a global variable that the template switches on. If the global variable does not exist, the default portion of the switch statement is used. On the example below (div based template) the left column is eliminated and the component (or mainbody rendering) has a full width single column.
This is on a Real Estate website, and is used for a few selective screens where full width is required for the content. Site is http://mlshomequest.com and this global variable is used to display the initial search screen for the "MLS property search" in the horizontal menu at the top. Global variable is $sw.
Index.php, after header and pathway code, preceeding footer code. The code is messy, as it has evolved along with the needs on the website and many areas have been commented out:
Code: Select all
<?php
if (isset($GLOBALS['refo_template'])) {
$sw = $GLOBALS['refo_template'];
} else {
$sw = $option;
}
switch ($sw) {
//case 'com_simpleboard':
//case 'com_staticxt':
case 'wide':
echo '<div style="margin:0px;padding:0px;border:0px;width:100%;">';
break;
default:
?>
<div style="float:left;width:150px;padding:0px;border:0px;/*background:position:absolute;top:37px;*/">
<?php if ( mosCountModules( 'left' ) > 0 ) { ?>
<div class="blue" style="float:left;margin-top:0px;/*0px;padding:0px;background-color:#F4F0DF;border:1px solid #673D19;*/">
<?php mosLoadModules ( 'left' ); ?>
</div>
<?php }; ?>
<?php if ( mosCountModules( 'user1' ) > 0 ) { ?>
<div class="tan" style="float:left;margin-top:6px;/*padding:0px;background-color:#F4F8F4;border:1px solid #9966CC;*/">
<?php mosLoadModules ( 'user1' ); ?>
</div>
<?php }; ?>
<?php if ( mosCountModules( 'user2' ) > 0 ) { ?>
<div class="blue" style="float:left;margin-top:6px;/*padding:0px;background-color:#F4F4F8;border:1px solid #6699CC;*/">
<?php mosLoadModules ( 'user2' ); ?>
</div>
<?php }; ?>
<?php if ( mosCountModules( 'bottom' ) > 0 ) { ?>
<div class="tan" style="float:left;margin-top:6px;/*padding:0px;background-color:#F8F4F4;border:1px solid #CC6699;*/">
<?php mosLoadModules ( 'bottom' ); ?>
</div>
<?php }; ?>
</div>
<div style="float:right;/*width:590px;*/width:594px;overflow:hidden;/*margin-left:156px;margin-right:0;*//*width:auto;*//*padding-left:6px;*/padding:0;border:0px;*/">
<?php ;
break;
} ?>
The second method is switching based on $option variable, which allows me to effect the same change when needed for specific components. Site is http://roadstarclinic.com, and switch takes place for the com_simpleboard component option in the url, same disclaimer as above as the code has been evolving along with the site. This code creates the middle section in the window and footers, and based on switch evaluation either creates a three colum layout, or a two colum layout. Template is table based:
Code: Select all
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<?php switch ($option) {
case 'com_simpleboard':
?>
<?php if ( mosCountModules( 'right' ) > 0 ) { ?>
<td width="135px" align="right" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr align="left" valign="top" >
<td height="27" colspan="1" class="mainWindow">
<?php mosLoadModules ( 'right' ); ?>
</td>
</tr>
</table>
<br />
</td>
<?php }; ?>
<td valign="top">
<table width="100%" border="0" margin="0" align="center" cellpadding="5" cellspacing="0" >
<tr valign="top" border="0">
<td height="49" colspan="1" class="mainWindow" >
<table width="97%" height="34" border="0" align="center" cellpadding="0" cellspacing="0">
<?php include ("mainbody.php"); ?>
</td>
</tr>
<?php if ( mosCountModules( 'banners' ) > 0 ) { ?>
<tr>
<td align="center">
<table border="0" cellpadding="0" cellspacing="0" class="moduletable" style="text-align:center;width:480px;padding:5px;margin:10 0 5 0;">
<th align="center"> Road Star Clinic Supporting Sponsor - Please visit our friends at: </th>
<tr valign="top" >
<td height="31" colspan="1" align="center" class="mainWindow">
<?php mosLoadComponent( "banners" ); ?>
</td>
</tr>
</table>
</td>
</tr>
<?php }; ?>
</table>
</td>
</tr>
</table>
<?php
break;
default:
?>
<td width="135px" height="231" align="left" valign="top">
<?php if ( mosCountModules( 'left' ) > 0 ) { ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr align="left" valign="top" >
<td height="27" colspan="1" class="mainWindow">
<?php mosLoadModules ( 'left' ); ?>
</td>
</tr>
</table>
<?php }; ?>
<?php if ( mosCountModules( 'user1' ) > 0 ) { ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr align="left" valign="top" >
<td height="27" colspan="1" class="mainWindow" >
<?php mosLoadModules ( 'user1' ); ?>
</td>
</tr>
</table>
<?php }; ?>
<?php if ( mosCountModules( 'user2' ) > 0 ) { ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" valign="top">
<tr align="left" valign="top" >
<td height="27" colspan="1" class="mainWindow">
<?php mosLoadModules ( 'user2' ); ?>
</td>
</tr>
</table>
<br />
<?php }; ?>
<?php if ( mosCountModules( 'bottom' ) > 0 ) { ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr align="left" valign="top" >
<td height="27" colspan="1" class="mainWindow">
<?php mosLoadModules ( 'bottom' ); ?>
</td>
</tr>
</table>
<br />
<?php }; ?>
</td>
<td valign="top">
<table width="100%" border="0" margin="0" align="center" cellspacing="0" style="padding:0px 5px 0px 5px;" valign="top">
<tr valign="top" border="0">
<td height="49" colspan="1" class="mainWindow" width="97%" >
<!-- <table width="97%" height="34" border="0" align="center" cellpadding="0" cellspacing="0" valign="top"> -->
<?php include ("mainbody.php"); ?>
<!-- </table> -->
</td>
</tr>
<?php if ( mosCountModules( 'banners' ) > 0 ) { ?>
<tr>
<td align="center">
<table border="0" cellpadding="0" cellspacing="0" class="moduletable" style="text-align:center;width:480px;padding:5px;margin:10 0 5 0;">
<th align="center"> Road Star Clinic Supporting Sponsor - Please visit our friends at: </th>
<tr valign="top" >
<td height="31" colspan="1" align="center" class="mainWindow">
<?php mosLoadComponent( "banners" ); ?>
</td>
</tr>
</table>
</td>
</tr>
<?php }; ?>
</table>
</td>
<!-- </tr>
</table> -->
<?php if ( mosCountModules( 'right' ) > 0 ) { ?>
<td width="135px" align="right" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr align="left" valign="top" >
<td height="27" colspan="1" class="mainWindow">
<?php mosLoadModules ( 'right' ); ?>
</td>
</tr>
</table>
<br />
</td>
<?php }; ?>
</tr>
</table>
<?php ;
break;
} ?>
This could be done much more efficiently, but it does work. I worried about the length of the file initially, but as php ignores contents of a switch statement that it does not execute, the longer file added no significant time to a page load.
FWIW.... I clearly am NOT a template designer ::) , these examples are presented as another way to effect template outcome, not as expamles of ideal template coding.
GRAM
Last edited by gram on Sat Aug 20, 2005 8:13 pm, edited 1 time in total.
GRAM
http://coders.mlshomequest.com/ < -- Developer of samSiteMap component
http://coders.mlshomequest.com/ < -- Developer of samSiteMap component
Re: Assigning templates to forums or galleries
Thanks gram, I'll check into your way. I wasn't very happy with cloning and editing a template multiple times.
Cheers
Cheers
Freedom is not free!
It is however Open Source.
It is however Open Source.
- guilliam
- Joomla! Enthusiast
- Posts: 159
- Joined: Thu Aug 18, 2005 10:27 am
- Location: Sunny City Cebu, Philippines!
- Contact:
Re: Assigning templates to forums or galleries
^^gram just stated it ahead.. i do supprt that variable though.. not unless your site's concept cant really be done using a variable template.
but again, @camos what you first posted is nice for templates using tables too.. besides templates that are using tables are easier to deploy(on an amatuer level).. than the tableless.
kudos!
guilliam
but again, @camos what you first posted is nice for templates using tables too.. besides templates that are using tables are easier to deploy(on an amatuer level).. than the tableless.
kudos!
guilliam
"I was one of those who wondered why people would pay so much $$$$ to do something that was so much fun!" -R. Harkrider, Fortran Code Engr.
^If u read that in $GREEN, you clearly missed the HIGHLIGHTS!
http://www.joomlancers.com | http://www.joomlaconsultancy.net
^If u read that in $GREEN, you clearly missed the HIGHLIGHTS!
http://www.joomlancers.com | http://www.joomlaconsultancy.net
- guilliam
- Joomla! Enthusiast
- Posts: 159
- Joined: Thu Aug 18, 2005 10:27 am
- Location: Sunny City Cebu, Philippines!
- Contact:
Re: FAQ: Assigning templates to forums or galleries
worth being sticky.
"I was one of those who wondered why people would pay so much $$$$ to do something that was so much fun!" -R. Harkrider, Fortran Code Engr.
^If u read that in $GREEN, you clearly missed the HIGHLIGHTS!
http://www.joomlancers.com | http://www.joomlaconsultancy.net
^If u read that in $GREEN, you clearly missed the HIGHLIGHTS!
http://www.joomlancers.com | http://www.joomlaconsultancy.net