Sub templates: Difference between revisions From Online Manual

Jump to: navigation, search
m (1 revision)
m (2 revisions: Importing from local.)
(No difference)

Revision as of 19:41, 5 November 2009

I'm glad you asked. A sub template is what actually has the html in it. You can change, for example, the admin_login sub template to make the administrative password prompt look different. You could change the error sub template to change what is displayed upon an error.

It's important to note that sub templates are grouped within templates. The error sub template "template_fatal_error()" can be found in the Errors.template.php, just as shown below.

: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation"></a>

// Show an error message...

function template_fatal_error() {    global $context, $settings, $options, $txt;

   echo ' <table border="0" width="80%" cellspacing="0" align="center" cellpadding="4" class="tborder">    <tr class="titlebg">       <td>', $context['error_title'], '</td>    </tr>    <tr class="windowbg">       <td style="padding-top: 3ex; padding-bottom: 3ex;">          ', $context['error_message'], '       </td>    </tr> </table>';

   // Show a back button (using javascript.)    echo ' <div align="center" style="margin-top: 2ex;"> <a href="javascript:history.go(-1)">', $txt[250], '</a> </div>'; } Breaking it a part:

: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation"></a>

// Show an error message...

Is used for comments to guide and tell you what the following block of code is.

: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation"></a>

function template_fatal_error()

{ … } This is the sub template that will be executed upon an error.

: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation"></a>

global $context, $settings, $options, $txt;

This is a php declaration of some variables.

: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation"></a>

echo '

<table border="0" width="80%" cellspacing="0" align="center" cellpadding="4" class="tborder">    <tr class="titlebg">       <td>', $context['error_title'], '</td>    </tr>    <tr class="windowbg">       <td style="padding-top: 3ex; padding-bottom: 3ex;">          ', $context['error_message'], '       </td>    </tr> </table>'; This is the actual HTML that will be shown (echo) to the browser. Note the use of $context there.

: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation"></a>

// Show a back button (using javascript.)

Another comment.

: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation"></a>

   echo '

<div align="center" style="margin-top: 2ex;"> <a href="javascript:history.go(-1)">', $txt[250], '</a> </div>'; Another block of HTML.

Next: [" class="bbc_link">Where do I find the templates and sub templates?]



Advertisement: