I described the process I went through to have a different osCmax home page template from the rest of the site in another post.
When I finished I realised that the method had a few issues and in particular it meant that the changes impacted the whole site not just that template.
So my goal here is to provide an alternative method that moves some of the changes into the template to minimise the impact on the core files and to make the template switching option work even with these changes.
The change I want to make is to move the decision process around the use of more than one main_page.tpl.php type file.
Start in main_page.tpl.php lines 11 to 15:
require(DIR_WS_INCLUDES . ‘meta_tags.php’);
//require(DIR_WS_INCLUDES . ‘counter.php’);$bts_php_array = bts_read_php();
$bts_html_array = bts_read_html($bts_php_array);
Change lines 14 & 15:
require(DIR_WS_INCLUDES . ‘meta_tags.php’);
//require(DIR_WS_INCLUDES . ‘counter.php’);$bts_php_array = bts_read_php($php_template);
$bts_html_array = bts_read_html($bts_php_array, $html_template);
Add in this section before line 14 so it looks like this:
// if there is an alternate file and if this is called from index.php
if ((file_exists(‘main_index_page.code.php’)) ||
(substr($_SERVER[‘PHP_SELF’], -9) == ‘index.php’)) {
$php_template = ‘main_index_page.code.php’;
$html_template = ‘main_index_page.html’;
} else {
$php_template = ‘main_page.code.php’;
$html_template = ‘main_page.html’;
}
Then move down to what should now be line 41
function bts_read_php($php_template = ‘main_page.code.php’) {
Change this to
function bts_read_php($php_template) {
Next change the other function at line 60
function bts_read_html($php_code_array, $html_template = ‘main_page.html’) {
Change this to
function bts_read_html($php_code_array, $html_template) {
Close that file.
Ok, so if we had done the earlier method then we need to undo the change to /index.php
Go back to the index.php file and change around line 335 is
include (bts_select(‘main_index’)); // BTSv1.5
Change this back to
include (bts_select(‘main’)); // BTSv1.5
Close index.php as this is finished with.
Finally, create the main_index_page.code.php and main_index_page.html. Note that a main_index_page.tpl.php is not required in this method.
So what does this do? This allows us to add multiple main_page options (just add more if file_exists type options) and it means that the template switching option will still operate.