Adding a static page within template_main_above & template_main_below

Started by –Michael, May 13, 2005, 01:12:33 PM

Previous topic - Next topic

–Michael

Hi again,

I would like to add a static page which displays some html content.

This static page should include template_main_above and template_main_below, so that the content itself is displayed in the main section (where usually the boards are displayed -- or e.g. in case of a search all the search options are displayed.).
The source for the content should be a file containing html.

What would be the best to realize this? I think of a php-file which needs to be called. This php file should have three sections:
1) including template_main_above
2) including the html code
3) including template_main_below

Would that be the way to go? Any other suggestions? Or am I reinventing the wheel and there is already a simple possibility to realize this?

Thanks in advance,
Michael
My SMF Mod: Static Page Mod


–Michael

[Unknown], I'd like to do the opposite: not integrating the forum into an existing site, but just integrating a static page into the SMF.

But I have found a solution so far:

1. modify index.php in the root directory: add a member to the actions array, e.g.:
'rules' => array('_Rules.php', 'DisplayRules')

2. create a new php-file in Sources/ directory (filename in my example: _Rules.php):
<?php

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


function 
DisplayRules()
{
loadTemplate('_Rules');
}

?>


3. Create an xxx.template.php in themes directory (filename in my example: _Rules.template.php):
<?php
// Version: 1.0; Rules MW

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

echo "Hello world, I am some text";

}

?>


Now, the static page can be called by the URL www.site.com/forum/index.php?action=rules

Regards,
Michael
My SMF Mod: Static Page Mod

[Unknown]

Actually, if you read it more closely you might see it does cover your question ;).

<?php

error_reporting
(E_ALL);

$ssi_theme 1;
$ssi_layers = array('main');

// If you want SSI.php to start gzipping for you ;).
$ssi_gzip true;

require(
'forum/SSI.php');

?>


Static content goes here.

<?php

ssi_shutdown
();

?>


-[Unknown]

–Michael

You're right, I should have read it more closely  ;)

Thank you,
Michael
My SMF Mod: Static Page Mod

dbrown

You should consider that the code above does not incorporate a title - it would just show the link in the title bar. Adjust the code for WHATEVER.php to look like this:

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

function 
DisplayWHATEVER() {
global 
$context;
$context['page_title'] = 'WHATEVER PAGE TITLE';
// This is gonna be needed...
loadTemplate('WHATEVER');
}
?>
Please do not PM me with support questions.  You will get better and faster responses by contacting someone who has a clue. Thank you.

ladyshanae

This works wonderfully!  Thank you for the instructions!

londonhogfan

http://rota.killerpings.ws/forums/index.php?action=roster

"Unable to load the 'main' template. "


using RC2... any ideas?



nevermind... Im teh n00b.  Got it.

Cavan

Thank you to everyone above who made adding tabs to the theme I use a real breeze.

I think it may be safe to advise that you also add the following if you're using the Orange LT theme (by panic):

Using a links page I've added to my site as an example, add to www/Themes/orange-lt113v1/index.template.php (around line 360):

// Show [Links] button.
    echo '<li><a href="', $scripturl, '?action=links">' , $txt[999] , '</a></li>';


And in www/Themes/orange-lt113v1/languages/Modifications,english-utf8.php, add:

$txt[999] = 'Links';

Notice that I entered "999" as the text number; starting with a high number like this may help you to remember additions to this particular file. Or not. ;)

Now that you've added this code (and you've previously followed Michael's steps above) you should see a Links tab at the top of your page, right next to the Register tab.

In summary, if you're using panic's Orange LT theme, you will need to edit/create at 5 files using Michael's method (same example):

www/index.php -edit

www/Sources/Links.php -create/edit

www/Themes/orange-lt113v1/index.template.php - edit

www/Themes/orange-lt113v1/Links.template.php - create/edit

www/Themes/orange-lt113v1/languages/Modifications.english-utf8.php - edit

Hope this helps someone.

Bulakbol

Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

geeks4share

Hey guy,

I have add a tab to my menu, and created the pages also. But the problem is that when someone click on the newly added tab, it is not getting highlighted like the other tabs. I tried in fixing this problem but i failed. Can anyone help me out of this problem.


Thanks
Geeks4Share

Advertisement: