Creating new pages in SMF - Printable Version +- Support Forums (https://www.supportforums.net) +-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87) +--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18) +---- Forum: PHP The Hypertext Preprocessor (https://www.supportforums.net/forumdisplay.php?fid=21) +---- Thread: Creating new pages in SMF (/showthread.php?tid=15449) |
Creating new pages in SMF - Project Evolution - 01-09-2011 In this tutorial you will learn how to create new pages in SMF. By this I mean your page will be completely integrated into SMF's template system, also done by this, your page will have a link embedded into SMF. In this example, I will use a page for something such as highscores. Lets begin. In order to have our pages embedded into SMF's source, we need to create a new element in the $actionArray in index.php. Head on over to the main directory of your SMF package and open up index.php. Next off search for, Code: // Here's the monstrous $_REQUEST['action'] array - $_REQUEST['action'] => array($file, $function). And below that we will add a new element, Code: 'highscores' => array('Highscores.php', 'Highscores'), Now to explain whats being done here.
Code: <?php As you can see here, this may be confusing at first. But try and stick with the comments. Next off we are going to go into our Themes directory and create a new php file called Highscores.template.php. This file is the actual aesthetic look of the page. You may be asking: "How does SMF know which template file to use?". Simple, Code: loadTemplate('Highscores'); Here is our Highscores.template.php file, Code: <?php
Code: $context['message'] = 'bob'; In your Highscores.template.php replace this, Code: function template_main() { With, Code: function template_main() { This will print: my name is bob.As you can see, the $context variable can be used to hold information which can then be displayed on your pages. Hopefully you have an idea how this works. And thats it, cheers. ~ Anthony` RE: Creating new pages in SMF - Sam - 01-09-2011 Just decided to post a load of tutorials eh? Also when I was using SMF I just used a custom mod to create new pages and it added in the template automatically... However, it is again an another well written and informative tutorial. RE: Creating new pages in SMF - Project Evolution - 01-09-2011 (01-09-2011, 05:42 PM)Sam Wrote: Just decided to post a load of tutorials eh? Also when I was using SMF I just used a custom mod to create new pages and it added in the template automatically... Yes hahaha, I havnt been posting things on this site in awhile. And yes that is the easier way to do it, however I wrote this for any interested users wanting to learn to write modifications. I will probably start focusing more on teaching people how to author modifications. RE: Creating new pages in SMF - w00pz - 01-10-2011 Nice tut Might become handy some day |