osCmax Template main page different from rest of site

Depending on which posts you read in the osCmax forums you get a different lot of questions around handling having a different main or index page from the rest of the site.

The forum article on BTS templates has what I needed to make these changes, but it’s buried down the page. Open the forum article and search in the page for ‘main2’ and you’ll find the relevant information. So why write this up? Because I find some of the instructions ambiguous.

In the catalog or / directory of the osCmax site each of the .php files that controls a page includes a control link to the main_page.tpl.php

[php]include (bts_select(‘main’)); // BTSv1.5
[/php]

is found in the code (generally near the end of the file) and the activity / actions of the file push the results off to the template for display.

In this case I want to modify the /index.php file  and rather than using main2, I’ll name it as main_index.

Open the /index.php and at the very end of the file around line 335 is

include (bts_select(‘main’)); // BTSv1.5

Change this to

include (bts_select(‘main_index’)); // BTSv1.5

Close index.php as this is finished with.

Open /includes/configure_bts.php at line 19 copy the existing line

define(‘TEMPLATENAME_MAIN_PAGE’, ‘main_page.tpl.php’);

and paste it again and edit as the second line for the new page template

define(‘TEMPLATENAME_MAIN_PAGE’, ‘main_page.tpl.php’);
define(‘TEMPLATENAME_MAIN_INDEX_PAGE’, ‘main_index_page.tpl.php’);

Then find at around line 43

case ‘main’:
// default or main_page
if(is_file(DIR_WS_TEMPLATES . TEMPLATENAME_MAIN_PAGE)) {
$path = (DIR_WS_TEMPLATES . TEMPLATENAME_MAIN_PAGE);
} else {
$path = (DIR_WS_TEMPLATES_FALLBACK . TEMPLATENAME_MAIN_PAGE);
}
break;

and copy and paste this as a second block immediately below the first and edit it as shown

case ‘main’:
// default or main_page
if(is_file(DIR_WS_TEMPLATES . TEMPLATENAME_MAIN_PAGE)) {
$path = (DIR_WS_TEMPLATES . TEMPLATENAME_MAIN_PAGE);
} else {
$path = (DIR_WS_TEMPLATES_FALLBACK . TEMPLATENAME_MAIN_PAGE);
}
break;

case ‘main_index’:
// default or main_page
if(is_file(DIR_WS_TEMPLATES . TEMPLATENAME_MAIN_INDEX_PAGE)) {
$path = (DIR_WS_TEMPLATES . TEMPLATENAME_MAIN_INDEX_PAGE);
} else {
$path = (DIR_WS_TEMPLATES_FALLBACK . TEMPLATENAME_MAIN_INDEX_PAGE);
}
break;

Close the configure_bts.php file as this is finished with.

Next in the template directory that you are using (I cover that bit elsewhere) copy the

main_page.tpl.php
main_page.html
main_page.code.php

as new files:

main_index_page.tpl.php
main_index_page.html
main_index_page.code.php

If you use a text editor like EditPlus then opening the files and using Save As is another option.

The final step is to edit the main_index_page.tpl.php file

There are two lines that reference the other files:
Line 33:

function bts_read_php($php_template = ‘main_page.code.php’) {

change to

function bts_read_php($php_template = ‘main_index_page.code.php’) {

and line 52:

function bts_read_html($php_code_array, $html_template = ‘main_page.html’) {

change to

function bts_read_html($php_code_array, $html_template = ‘main_index_page.html’) {

Close this file as it is ready.

Make some changes in the main_index.html page so that you can see a difference and test your new template main page and another page to see that you have it all working. Once this is done, editing the two separate file pairs of .html and .code.php will allow for the setup of two types of layouts.

Of course, this can then be applied for a third or many multiples of layouts within the same site or template.

Now, this is the suggested process gleaned from various forum posts. I think there is a better way as I’d prefer to minimise the modifying of the core application files and this breaks the template switching process.

 

 

One reply

  1. […] described the process I went through to have a different osCmax home page template from the rest of the site in another […]

Leave a Reply

Your email address will not be published.