Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: IceXaos on September 28, 2010, 11:37:45 AM

Title: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: IceXaos on September 28, 2010, 11:37:45 AM
Step 1


We're going to start by creating the actions needed to get our custom page.  If you try to go to it, you'll obviously get errors as we've not yet created it.

./index.php

Find
        'movetopic2' => array('MoveTopic.php', 'MoveTopic2'),

Add After
        'mypage' => array('MyPage.php', 'MyPage'),

What this does, is when the action "mypage" is called on, it will point to ./Sources/MyPage.php and inside that, the function MyPage().

Step 2


Now, to access that page easily, we're going to create a tab to direct us there.

./Sources/Subs.php

Find
            'home' => array(
                'title' => 'Home',
                'href' => $scripturl,
                'show' => true,
                'sub_buttons' => array(
                ),
            ),


Add After
            'mypage' => array(
                'title' => 'What The Tab Says',
                'href' => $scripturl . '?action=mypage',
                'show' => true,
                'sub_buttons' => array(
                ),
            ),


This is going to add the tab we need to be able to click.  Remember to change the title.

Find
    if (isset($context['menu_buttons'][$context['current_action']]))
        $current_action = $context['current_action'];


Add After
    elseif ($context['current_action'] == 'mypage')
        $current_action = 'mypage';


Basically if you're using the action "mypage", set your current action to "mypage".  This will cause the tab to be highlighted while you're using the page.

Step 3


Now it's time to create our custom page.  Here's a basic template I use.  Remember, this doesn't exist yet!

./Sources/MyPage.php
<?php

if (!defined('SMF'))
die(
'Hacking attempt...');

function 
MyPage() {
    global 
$context;
    
$context['page_title'] = 'My Page Title Goes Here';

    function 
template_main() {
        echo 
'<center><b>Content goes here.  Remember to echo all HTML as this is in PHP.</b></center>';
    }
    
}

?>



Once you do this, you should be able to see your custom page by going to http://yoursite.com/index.php?action=mypage

If I've missed anything, let me know and I'll add it.  Also, a thanks to Cicka (I think that's how you spell it) for helping me learn a while ago, what all needs to be done.

If you have any questions, feel free to ask in a reply here.
Title: Re: How To Create Custom Pages [2.0 RC3]
Post by: Kays on September 28, 2010, 11:44:46 AM
In that custom page you do need to set a value for $context['current_action'] for the button to be active.

Or else you can change:


    elseif ($context['current_action'] == 'mypage')
        $current_action = 'mypage';


to:


    elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'mypage')
        $current_action = 'mypage';
Title: Re: How To Create Custom Pages [2.0 RC3]
Post by: IceXaos on September 28, 2010, 11:47:50 AM
Quote from: Kays on September 28, 2010, 11:44:46 AM
In that custom page you do need to set a value for $context['current_action'] for the button to be active.

Or else you can change:


    elseif ($context['current_action'] == 'mypage')
        $current_action = 'mypage';


to:


    elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'mypage')
        $current_action = 'mypage';

You don't need to, as I'm pretty sure that's set by _GET variables.  I've never really checked, but it works like that for every page I've added.
Title: Re: How To Create Custom Pages [2.0 RC3]
Post by: Alex' Manson on September 28, 2010, 11:50:42 AM
lets say my page is called "SiskoPlanet"
so this:

  'mypage' => array(
                'title' => 'What The Tab Says',
                'href' => $scripturl . '?action=mypage',
                'show' => true,
                'sub_buttons' => array(
                ),
            ),

Will Be:
'SiskoPlanet' => array(
                'title' => 'SiskoPlanet',
                'href' => $scripturl . '?action=SiskoPlanet',
                'show' => true,
                'sub_buttons' => array(
                ),
            ),

and

  elseif ($context['current_action'] == 'mypage')
        $current_action = 'mypage';

will be:

  elseif ($context['current_action'] == 'SiskoPlanet')
        $current_action = 'SiskoPlanet';

???
Title: Re: How To Create Custom Pages [2.0 RC3]
Post by: IceXaos on September 28, 2010, 11:51:51 AM
If you want the action to be called SiskoPlanet, then you'll need to change that in every location the action is stated.
Title: Re: How To Create Custom Pages [2.0 RC3]
Post by: zamg0d1 on September 28, 2010, 12:02:23 PM
Ah, I will try with this one, but how to add sub-actions?
Title: Re: How To Create Custom Pages [2.0 RC3]
Post by: IceXaos on September 28, 2010, 12:03:51 PM
For a sub-action, which I assume you're talking about active tabs.

    elseif ($context['current_action'] == 'mysubpage')
        $current_action = 'mypage';


This will activate "mypage" tab if you're on "mysubpage".
Title: Re: How To Create Custom Pages [2.0 RC3]
Post by: Kays on September 28, 2010, 12:15:55 PM
Quote
You don't need to, as I'm pretty sure that's set by _GET variables.  I've never really checked, but it works like that for every page I've added.

Yes, you are correct on that. That's something new for 2.0 I wasn't aware of.

But it will only work if that page is in accessed using $_GET['action']. For other pages $context['current_action'] does need to be set.
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: IceXaos on September 28, 2010, 12:19:33 PM
Quote from: Kays on September 28, 2010, 12:15:55 PM
Quote
You don't need to, as I'm pretty sure that's set by _GET variables.  I've never really checked, but it works like that for every page I've added.

Yes, you are correct on that. That's something new for 2.0 I wasn't aware of.

But it will only work if that page is in accessed using $_GET['action']. For other pages $context['current_action'] does need to be set.
Yep, but adding it like this, you're kind'a forced to use actions to get to it, plus with a tab, it's just a click away.
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: Kays on September 28, 2010, 12:28:07 PM
Yes, but people do also add the menu bar to the home page of their site. Or to other pages where SSI.php is included and which are not accessed using the action array.
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: IceXaos on September 28, 2010, 12:31:08 PM
Quote from: Kays on September 28, 2010, 12:28:07 PM
Yes, but people do also add the menu bar to the home page of their site. Or to other pages where SSI.php is included and which are not accessed using the action array.
True.  I was just attempting to cover the main idea here.  With this, they're capable of creating pages integrated with the forum, which you access by actions, as well as using PHP along with HTML.  I couldn't possibly cover every thing a user may do.
Title: Re: How To Create Custom Pages [2.0 RC3]
Post by: zamg0d1 on September 28, 2010, 03:19:19 PM
Quote from: IceXaos on September 28, 2010, 12:03:51 PM
For a sub-action, which I assume you're talking about active tabs.

    elseif ($context['current_action'] == 'mysubpage')
        $current_action = 'mypage';


This will activate "mypage" tab if you're on "mysubpage".
No more like 'forum/index.php?action=admin;area=featuresettings', so in the Admin action there's a new action, that's what I ment.
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: IceXaos on September 28, 2010, 03:32:15 PM
Quote from: zamg0d1 on September 28, 2010, 03:19:19 PM
Quote from: IceXaos on September 28, 2010, 12:03:51 PM
For a sub-action, which I assume you're talking about active tabs.

    elseif ($context['current_action'] == 'mysubpage')
        $current_action = 'mypage';


This will activate "mypage" tab if you're on "mysubpage".
No more like 'forum/index.php?action=admin;area=featuresettings', so in the Admin action there's a new action, that's what I ment.
if ($_GET['area'] == 'featuresettings') { do this }
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: zamg0d1 on September 28, 2010, 03:56:50 PM
Quote from: IceXaos on September 28, 2010, 03:32:15 PM
Quote from: zamg0d1 on September 28, 2010, 03:19:19 PM
Quote from: IceXaos on September 28, 2010, 12:03:51 PM
For a sub-action, which I assume you're talking about active tabs.

    elseif ($context['current_action'] == 'mysubpage')
        $current_action = 'mypage';


This will activate "mypage" tab if you're on "mysubpage".
No more like 'forum/index.php?action=admin;area=featuresettings', so in the Admin action there's a new action, that's what I ment.
if ($_GET['area'] == 'featuresettings') { do this }
Ah you mean like this:
<?php

if (!defined('SMF'))
die(
'Hacking attempt...');

function 
Newspost() {
    global 
$context;
    
$context['page_title'] = 'My Page Title Goes Here';

    function 
template_main() {
         
$able = array('1''2''help''verzonden''none'); // pages allowed
         
$id 'none'// standard page
         
if(!empty($_GET['id']) && in_array($_GET['id'], $able)) {
            
// allowed so we load that page
            
$id $_GET['id'];
         }
         
        if (
$_GET['id'] == 'help') {         include_once("mh.gaming-freak.nl/news/news/help.php$id.php"); }
    }
    
}

?>


But with this url it won't work :( http://mh.gaming-freak.nl/forum/index.php?action=newspost;id=help



(I'm PHP noob but trying to make it work :O)
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: IceXaos on September 28, 2010, 04:07:02 PM
Why do it twice?  You're going to to check with an if statement to do certain actions anyways, so you may as well just throw it in to the main statement.

if ($_GET['id'] == '1') {
   1();
} elseif ($_GET['id'] == '2') {
   2();
}
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: IceXaos on September 28, 2010, 04:08:45 PM
Sorry, just actually looked at it.  What's the point of all this?

         $able = array('1', '2', 'help', 'verzonden', 'none'); // pages allowed
         $id = 'none'; // standard page
         if(!empty($_GET['id']) && in_array($_GET['id'], $able)) {
            // allowed so we load that page
            $id = $_GET['id'];
         }

You check again anyways, which is gonna make it completely pointless.
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: Hj Ahmad Rasyid Hj Ismail on September 28, 2010, 04:15:50 PM
No offence IX, I prefer using a mod to do this. I am little bit dizzy with codes lately. I haven't got time to finish my latest mods too.
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: IceXaos on September 28, 2010, 04:24:01 PM
Quote from: ahrasis on September 28, 2010, 04:15:50 PM
No offence IX, I prefer using a mod to do this. I am little bit dizzy with codes lately. I haven't got time to finish my latest mods too.
Most MOD's only allow you to add a certain amount of pages, and it's not always a lot.  I believe there is one that allows up to 6, but that's as high as it goes AFAIK.  Anyways, this was made to help out someone with tab problems, but since he didn't have his pages set up within the forums, I figured I'd make a quick tutorial and show how.  He wanted to add PHP to custom pages, and I'm not sure if any MOD's allow that, but he didn't seem to have any luck with it.  I've never really tried custom page MOD's myself, since I don't see the point for something so quick.
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: Hj Ahmad Rasyid Hj Ismail on September 28, 2010, 04:44:24 PM
I agree on that. Most mods that create page don't create tab for the created page. Normally, we have to do it manually. And some of them do have limitations. There is a nice mod from arantorsmod site that can easily create tab menu. I would recommend that mod (or any mods from Arantor - well, they call him The Captain). Personally, I used cms mod (no longer available from SMF mod site. I will change to Arantor's mod later) for managing my main menu and SP for creating page.
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: Masterd on November 01, 2010, 07:32:13 AM
http://www.simplemachines.org/community/index.php?topic=261880.0 (http://www.simplemachines.org/community/index.php?topic=261880.0)

http://www.simplemachines.org/community/index.php?topic=23864.0 (http://www.simplemachines.org/community/index.php?topic=23864.0)
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: Alex' Manson on November 01, 2010, 10:48:20 AM
hmm, iceXaos's one is better.. :P
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: Masterd on November 01, 2010, 11:09:32 AM
It's almost the same.
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: Computer Robot on December 08, 2010, 10:37:35 AM
How can I modify this to point to a parent directory.  I just want a button to go to the home page of my website but the forum folder is in a subdirectory of the homepage.  ie http://www.homepcrepairsandupgrades.co.uk/forum/ (http://www.homepcrepairsandupgrades.co.uk/forum/)

I added the first 2 steps from the original post to make a "Home Page" tab after Home but its not directed to anything. 
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: Computer Robot on December 08, 2010, 12:30:18 PM
The new tab is actually directed to the forum home page.  I think this is because I change the "mypage" into "home page" somewhere in the code and its calling that function.  What I want though is to go to http://www.homepcrepairsandupgrades.co.uk/ (http://www.homepcrepairsandupgrades.co.uk/)  a parent directory of my forum. 
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: IceXaos on December 08, 2010, 08:01:52 PM
Quote from: Computer Robot on December 08, 2010, 12:30:18 PM
The new tab is actually directed to the forum home page.  I think this is because I change the "mypage" into "home page" somewhere in the code and its calling that function.  What I want though is to go to http://www.homepcrepairsandupgrades.co.uk/ (http://www.homepcrepairsandupgrades.co.uk/)  a parent directory of my forum. 
Is the "homepage" your linking to off-site, or is it the actual homepage of the forum?  If it's off-site, you will not need to do the 2nd part of step 2.  Now, you can name the action whatever you like as long as it's not taken, simply set the title to what you'd like it to say and the href to the link you just said.  If you end up lost, let me know and I can help you over teamviewer and show you how, or I can modify it for you and send it back.
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: Computer Robot on December 09, 2010, 05:01:09 AM
HI thanks it worked.  I tried to change the 'Home' button to 'Forum Home'  so I could give my homepage that title but it shrank the button to minimal width and no text.  I then removed the $txt from the code and it went back to normal.  Shouldn't be a problem should it?
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: Hj Ahmad Rasyid Hj Ismail on December 09, 2010, 05:07:52 AM
IMO, if you follow the OP correctly, then you will realized that there is no need to put $txt as that is used only if you want to call the menu from language file.
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: Computer Robot on December 09, 2010, 05:33:55 AM
Quote from: ahrasis on December 09, 2010, 05:07:52 AM
IMO, if you follow the OP correctly, then you will realized that there is no need to put $txt as that is used only if you want to call the menu from language file.

Sorry dont know what that means being a noob.  I will point out though that I changed one of the original buttons installed along with the forum i.e the HOME tab. 
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: IceXaos on December 09, 2010, 06:07:25 AM
When you use, for example $txt['home_tab'] you are calling on the language file where that variable is defined.  There is no reason to define them in the language file unless you're anal, in which you could also create a template file rather than stick everything inside of the source file.

Rather than use something like $txt['home'] just use 'home'.
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: radioz on December 10, 2010, 07:37:50 AM
IceXaos,

Could your step #2 be used for an image?  I have managed to change the smflogo and move it to the left.I would like to link that image to the home page of my external main website.  I am using a veryy slightly modified (logo) Curve theme,

Thanks!

Jon
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: IceXaos on December 12, 2010, 02:33:40 AM
Quote from: radioz on December 10, 2010, 07:37:50 AM
IceXaos,

Could your step #2 be used for an image?  I have managed to change the smflogo and move it to the left.I would like to link that image to the home page of my external main website.  I am using a veryy slightly modified (logo) Curve theme,

Thanks!

Jon
If you're wanting a regular image linked to another page, you would simply use HTML code.
<a href="http://...."><img src="http://.../*.jpg"></a>

Or, did you mean you wanted to add an image to the drop-down menu?  If so, did you mean add an icon, or a small banner?
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: advance on December 13, 2010, 07:16:45 AM
I've got a different question. I want to make a button ( and sub buttons ) that direct to the pages on another server but those pages need to be rendered inside forum, not in new page/window.

Sorry for my english :).

Regards.
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: IceXaos on December 15, 2010, 07:23:49 AM
Quote from: advance on December 13, 2010, 07:16:45 AM
I've got a different question. I want to make a button ( and sub buttons ) that direct to the pages on another server but those pages need to be rendered inside forum, not in new page/window.

Sorry for my english :).

Regards.
There are two ways you can go about doing this, but if you have many questions, please make a thread in the coding support for more information.

You could go about it using Javascript/JQuery using a new page like this and only inserting a div into the page, which can contain data by default and will be changed as you choose different links (which would link to use JQuery, not a URL).

Alternatively, you could use an iFrame on the page, and this should be pretty self-explanatory.

Good luck.
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: Hack-King on December 27, 2010, 10:41:36 AM
isnt there any mod for dat?
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: IceXaos on December 27, 2010, 07:13:26 PM
Quote from: Hack-King on December 27, 2010, 10:41:36 AM
isnt there any mod for dat?
Yes, there's a few, just search.
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: lucas-ruroken on January 03, 2011, 01:05:17 AM
so.. good tip
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: IceXaos on January 03, 2011, 12:48:58 PM
Quote from: lucas-ruroken on January 03, 2011, 01:05:17 AM
so.. good tip
:) Figured it may be of use as it's something that took me a little to figure out when I first started using SMF.  For me, the problem was finding everything, but this should cover people who don't really know PHP, and those who need help locating things.

Almost 3K views .. :P
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: lucas-ruroken on January 03, 2011, 05:33:56 PM
Yeah, it's a good tip (H) :P
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: Hj Ahmad Rasyid Hj Ismail on January 03, 2011, 06:54:58 PM
Quote from: IceXaos on January 03, 2011, 12:48:58 PM
Quote from: lucas-ruroken on January 03, 2011, 01:05:17 AM
so.. good tip
:) Figured it may be of use as it's something that took me a little to figure out when I first started using SMF.  For me, the problem was finding everything, but this should cover people who don't really know PHP, and those who need help locating things.

Almost 3K views .. :P
IX - This thread is indeed useful. Plus your avatar and sig pic might be distracting them too  8)
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: inter on January 11, 2011, 10:32:52 AM
Excuse for my English. :P

Thanks for this instruction, but are necessary for me more information how to make that a page title was added in a menu tree?

How to make on this page subpage in which scenarios were fulfilled:

http://myforum/index.php?action=mypage;sa=?;in=?;?=?;...

(http://s54.radikal.ru/i145/1101/32/80efce59b9ba.gif)
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: lucas-ruroken on January 11, 2011, 10:37:45 AM
in your custom function.... You can add

global $context;

$context['linktree'][] = array(
'url' => 'YOUR URL',
'name' => 'YOUR TITLE'
);
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: inter on January 11, 2011, 10:54:57 AM
Quote from: lucas-ruroken on January 11, 2011, 10:37:45 AM
in your custom function.... You can add

global $context;

$context['linktree'][] = array(
'url' => 'YOUR URL',
'name' => 'YOUR TITLE'
);

I don't understand  :P
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: Mikirin on January 11, 2011, 11:22:51 AM
I'm sorry for not reading on, but I am wondering, does it work for external links too?
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: lucas-ruroken on January 11, 2011, 12:28:21 PM
Quote
function MyPage() {
    global $context;
    $context['page_title'] = 'My Page Title Goes Here';

    $context['linktree'][] = array(
        'url' => 'YOUR URL',
        'name' => 'NAME OF THE LINKTREE',
    );


    function template_main() {
        echo '<center><b>Content goes here.  Remember to echo all HTML as this is in PHP.</b></center>';
    }
   
}
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: inter on January 11, 2011, 01:04:20 PM
Quote from: lucas-ruroken on January 11, 2011, 12:28:21 PM
Quote
function MyPage() {
    global $context;
    $context['page_title'] = 'My Page Title Goes Here';

    $context['linktree'][] = array(
        'url' => 'YOUR URL',
        'name' => 'NAME OF THE LINKTREE',
    );


    function template_main() {
        echo '<center><b>Content goes here.  Remember to echo all HTML as this is in PHP.</b></center>';
    }
   
}

:D super!!!

And how to do similar for subpage???

http://localhost/forum/index.php?action=mypage;sa=post; ...

sorry my English  :P
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: lucas-ruroken on January 11, 2011, 01:45:17 PM
It's more complex than that....

You can open one mod That use it... And check it.
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: Mikirin on January 11, 2011, 05:47:12 PM
Thank you, Lucas.
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: inter on January 12, 2011, 06:12:34 AM
How to connect language files?

How to connect .Themes/default/MyPage.template.php?




global $context, $txt, $modSettings;

I have a little understood :)
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: lucas-ruroken on January 12, 2011, 08:10:10 AM
in your function... add

if(loadLanguage('MyPage') == false)
   loadLanguage('MyPage','english');


if not load MyPage.yourlanguage.php, load MyPage.english.php ;)
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: inter on January 13, 2011, 07:19:07 AM


$subActions = array(

'view' => 'ViewPage',
);


'view' - http://localhost/forum/index.php&action=mypage;sa=view

=> 'ViewPage', - function for display subpage ???

Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: lucas-ruroken on January 13, 2011, 10:18:50 AM
exactly...

you can use that as example.....


<?php

function MyPage()
{
//Load our custom template MyPage.template.php
loadTemplate('MyPage');

//Load our subactions sa=
$sa = array(
//This is the default action, you can load it action=mypage or action=mypage;sa=default... it's the same
'default' => 'DefaultFunction',
'download' => 'DownloadFunction',
'another' => 'AnotherFunction',
);

//that is for load subactions... if you are requesting a subaction, load it.... If It doesn't.... load defaulfunction
if(!empty($_REQUEST['sa']) && !empty($sa[$_REQUEST['sa']]))
$sa[$_REQUEST['sa']]();
else
DefaultFunction();

}

function 
DefaultFunction()
{
global $context$txt;

//Set the page title
$context['page_title'] = 'Default Page';

//Sub template.... You need to add in your MyPage.template.php function template_lucas_default()
$context['sub_template'] = 'lucas_default';

}

function 
DownloadFunction()
{
global $context$txt;

//Set the page title
$context['page_title'] = 'Download Page';

//Sub template.... You need to add in your MyPage.template.php function template_lucas_download()
$context['sub_template'] = 'lucas_download';

}

function 
AnotherFunction()
{
global $context$txt;

//Set the page title
$context['page_title'] = 'Another Page';

//Sub template.... You need to add in your MyPage.template.php function template_lucas_another()
$context['sub_template'] = 'lucas_another';

}


?>


It's very simple.... after that, you need add the differentes function template_ in your template file
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: larryhyman on February 16, 2011, 06:53:21 PM
I have been using this as a template: (please correct me if I am wrong)


<?php
$_REQUEST
['action'] = 'myshop';
$_GET['action'] = 'myshop';
require(
'smforums/SSI.php');
$context['page_title_html_safe'] = 'Welcome to My Shopping Cart';
$context['linktree'][] = array(
'url' => './myshop.php',
'name' => 'Shop',
);
template_header();
?>

<div class="windowbg" style="width:100%; margin-left: auto;margin-right: auto;">
   <span class="topslice"><span></span></span>
   <div class="content">
<!-- start html content -->



<!-- end html content -->
</div>
   <span class="botslice"><span></span></span>
</div>
<?php
template_footer
();
?>


This has been working very fine for me....
Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: larryhyman on February 17, 2011, 09:01:48 AM
I could not find the original post I got this info from but I found this....

Quote from: [SiNaN] on August 23, 2008, 01:47:26 PM
Yeah, I know. You must be using $ssi_layers = array('main');. As I understand, you want to set the current action in a custom page. To do this, before including SSI.php, add this code:

$_GET['action'] = 'custom';

When you are on that custom page, the $context['current_action'] will be equal to 'custom'.


and this...

Quote from: Arantor on April 24, 2010, 09:43:07 AM
$current_action is set based on the value of $_REQUEST['action'] which you'll see earlier in the code.

I believe you can set $_REQUEST['action'] in your code (BEFORE SSI.php is loaded) to 'mypage' or something, and then define 'mypage' => array(......) in the menu.

Everything does work fine for me....


Title: Re: How To Create Custom Pages + Tabs [2.0 RC3]
Post by: larryhyman on February 17, 2011, 09:35:48 PM
OK, I found the original post, I would really like to get some feedback on this, as it works for me, but is it wrong?

Quote from: ledor on September 21, 2010, 09:48:19 PM
I haven't seen this one. I'll read this and let you know later. Thanks.


Edit:
At last, I've solved my problem. Thanks for that link although it doesn't directly solved my problem but was able to find a solution based on the discussion. Here's what I've done:
Instead of adding

$context['current_action'] = 'home'

to my index.php (homepage), I've added the

$_REQUEST['action'] = 'home';
$_GET['action'] = 'home';


Then, on Subs.php I've changed the default current action to forum:

// Default to home. >> changed from 'home' to 'forum'
$current_action = 'forum';


That solved my problem.

Thanks a lot KEA!!!