How To Create Custom Pages + Tabs [2.0 RC3]

Started by IceXaos, September 28, 2010, 11:37:45 AM

Previous topic - Next topic

lucas-ruroken

in your custom function.... You can add

global $context;

$context['linktree'][] = array(
'url' => 'YOUR URL',
'name' => 'YOUR TITLE'
);
Adk Portal 3.1 is coming....

Design your universe!

inter

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
Sorry for my English

Mikirin

I'm sorry for not reading on, but I am wondering, does it work for external links too?

lucas-ruroken

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>';
    }
   
}
Adk Portal 3.1 is coming....

Design your universe!

inter

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
Sorry for my English

lucas-ruroken

It's more complex than that....

You can open one mod That use it... And check it.
Adk Portal 3.1 is coming....

Design your universe!


inter

#47
How to connect language files?

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




global $context, $txt, $modSettings;

I have a little understood :)
Sorry for my English

lucas-ruroken

in your function... add

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


if not load MyPage.yourlanguage.php, load MyPage.english.php ;)
Adk Portal 3.1 is coming....

Design your universe!

inter



$subActions = array(

'view' => 'ViewPage',
);


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

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

Sorry for my English

lucas-ruroken

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
Adk Portal 3.1 is coming....

Design your universe!

larryhyman

#51
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....
In god we trust, all others pay cash !

http://hyman.sytes.net

larryhyman

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....


In god we trust, all others pay cash !

http://hyman.sytes.net

larryhyman

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!!!

In god we trust, all others pay cash !

http://hyman.sytes.net

Advertisement: