Want to get involved in developing SMF, then why not lend a hand on our github!
Started by sangwe11, November 21, 2009, 07:26:14 PM
Quote from: Arantor on November 21, 2009, 08:04:33 PMIn the source file, set:$context['sub_template'] = 'name_of_subtemplate';Then when it's ready, template_name_of_subtemplate() will be loaded from the file from what loadTemplate was already executed.E.g. loadTemplate('wiki');$context['sub_template'] = 'edit_page';
Quote from: Arantor on November 21, 2009, 08:12:52 PMYeah, you put the name of the subtemplate function into the $context variable.I should have finished the above with that it calls template_edit_page.Generally you wouldn't have multiple subtemplates on a single page. It does happen, though, such as the poll template file being called from Display.php and Post.php, in which case you just call the template files individually from the subtemplate, like the BoardIndex template does to load the info center (which in 2.0 is a separate sub template)
Quote from: Arantor on November 21, 2009, 08:24:04 PMNo, you load a single template, and call the other functions if you need to.Like I pointed out, the BoardIndex template has two subtemplates.BoardIndex itself primarily loads the BoardIndex.template.php and doesn't set a subtemplate, so it loads template_main, which is fine.BoardIndex.template.php contains a second subtemplate, for the info centre, which is called manually at the end of template_main. Thus you only have one master subtemplate being used, and you call the other templates if you want them.Remember, subtemplates are just regular functions that output stuff. You set up the data in $context that you want to display, the template displays the HTML you give it. If you want to ensure the order is right, make your template function display it all in order. If it branches off to another subtemplate, just make sure that you're calling it in the right place.