Stop inheriting header, footer,... from index.template.php in Themes/default?

Started by themavesite, October 27, 2017, 03:24:35 AM

Previous topic - Next topic

themavesite

Templates in /Themes/default inherit most of their html from index.template.php
Now I want one page to look totally different than the forum. How do I stop a template from inheriting from index.template.php, so I can add a header and footer myself in the template file itself?

I already created the page and everything in the main_section already is styled the way I want, problem is that the header and footer and some other stuff still gets imported from index.template.php, how do I stop this behaviour for one specific template?
TMS Forums
Since 2008 and still going strong! Join today! http://forums.themavesite.com/index.php

Arantor

With difficulty but it is possible.

You create new _above and _below functions and replace $context['template_layers'] to point at the new layers.

themavesite

Quote from: Arantor on October 27, 2017, 04:10:15 AM
With difficulty but it is possible.

You create new _above and _below functions and replace $context['template_layers'] to point at the new layers.

Thank you for your reply, the only thing that isn't clear to me is what you mean with $context['template_layers']

link in TMS.php

loadTemplate('TMS');

The TMS template file:

function template_main()
{
global $context, $settings, $options, $txt, $scripturl;
echo '
<div id="tms_recent" class="main_section">
<div class="cat_bar">
<h3 class="catbg">
<span class="ie6_header floatleft"><img src="', $settings['images_url'], '/post/rt.png" alt="" class="icon" />The Most Recent Topics (limited to 100)</span>
</h3>
</div>';
foreach ($context['posts'] as $post)
{
echo '
<div class="', $post['alternate'] == 0 ? 'windowbg' : 'windowbg2', ' core_posts">
<span class="topslice"><span></span></span>
<div class="content">
<div class="topic_details">
<h5>', $post['subject'], '</h5><!--was link-->
<span class="smalltext">Posted <em> ', $post['time'];
echo'
</div>
<div class="list_posts">', $post['message'], '</div>
</div>
<span class="botslice clear"><span></span></span>
</div>';
}
echo '
<div class="pagesection">
<span>', $txt['pages'], ': ', $context['page_index'], '</span>
</div>
</div>';
}
?>


As you can see there are no template links besides the "TMS" one, yet it automatically uses the above and below templates in index.template.php
TMS Forums
Since 2008 and still going strong! Join today! http://forums.themavesite.com/index.php

Arantor

$context['template_layers'] is what controls which header and footer code to call.

In a Curve based theme, this is set to a list of two items, 'html' and 'body' which means it will run template_html_above, template_body_above, then the main part of the content, then template_body_below, then template_html_below. If you want to change the header footer templates for just one page or area, this is what you change.

themavesite

Quote from: Arantor on October 27, 2017, 05:25:51 AM
$context['template_layers'] is what controls which header and footer code to call.

In a Curve based theme, this is set to a list of two items, 'html' and 'body' which means it will run template_html_above, template_body_above, then the main part of the content, then template_body_below, then template_html_below. If you want to change the header footer templates for just one page or area, this is what you change.

I'm almost with you.. I think.

Instead of loadTemplate('TMS');, I should call them all manually and then point to new above and below templates?
Something like this?:

$context['template_html_above'] ;
$context['template_body_above'];
$context['TMS'];
$context['template_body_below'];
$context['template_html_below'] ;


Sadly this doesn't work

I have created the new functions, they're all called template_html_above/below/html_TMS
Only thing I don't know is how to call these instead of default ones
TMS Forums
Since 2008 and still going strong! Join today! http://forums.themavesite.com/index.php

Arantor

No, not at all.

The stock code, effectively, says:

$context['template_layers'] = array('html', 'body'):
$context['sub_template'] = 'my_template';

This, when it actually runs templates, then runs:
template_html_above();
template_body_above();
template_my_template();
template_body_below();
template_html_below();

Where the loadTemplate call is what makes sure template_my_template or whatever it is called is defined. The rest come from index.template.php which is loaded very early on.

Advertisement: