News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Sub templates

Started by music_man, April 13, 2005, 12:57:54 AM

Previous topic - Next topic

music_man

Hi

I was wondering how to make sub templates in the index.template.php file? There is a tutorial on how to have custom pages and I am not sure how to activate it properly.

Thanks

[Unknown]

Sub templates can be made in any file.  It's just terminology to clarify things; sub templates are functions, with the prefix "template_" in their name (for namespacing.)  Example:

function template_blah()
{
   global $context, $settings, $options, $scripturl, $txt, $modSettings;

   echo 'HI!!';
}

That's a sub template.

-[Unknown]

music_man

Thanks

Where do you put the function?

In another file? Or in the index.template.php.

Thanks

[Unknown]

If you put it in another file, you're putting it in another template.

It's best to separate out templates, because then it's easier to work them into certain themes.  Too many gets cluttered, and too few gets hard to modify and less efficient.

However, if you put it in another template, that template needs to be loaded before the sub template is available.

-[Unknown]

music_man

Okay.

So if I opened up my forum and typed in the address bar "http://www.myforum.com/index.php?action=aboutme"

Then how would the forum display that page regardless of what theme I choose, i.e. I can change my theme but the text on my custom page will stay the same.

In my index.php file do I make a function called template and then have the content of the template inside that function so when I type in the corresponding address I get shown that text inside my main template / theme?

Thanks

Advertisement: