News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

creating custom SMF-powered web pages

Started by 1MileCrash, July 17, 2005, 04:08:32 PM

Previous topic - Next topic

1MileCrash

I want to be able to make custom SMf powered web pages. For example, the same header and footer, and background, everything, but my own html content on the page. I know there is a very simple way to do this with vB, does the same apply for SMF?

This is what i want top do with SMF. Can i basically do the same thing with SMF?
The only thing php can't do is tell you how much milk is left in the fridge.




1MileCrash

thanks...

wow. That is really confusing. What are these "actions"? I dont quite understand. Would i be able to create a homepage, or a downloads page? etc.?
The only thing php can't do is tell you how much milk is left in the fridge.



dtm.exe

Quote from: Tippmaster on July 17, 2005, 04:31:34 PM
thanks...

wow. That is really confusing. What are these "actions"? I dont quite understand. Would i be able to create a homepage, or a downloads page? etc.?

It would end up being something like yoursite.com/index.php?action=downloads.

-Dan The Man

1MileCrash

understood. So it wouldnt be, a "file". I could just set up a redirect for the page, in the case of the homepage. Thanks for your help dan.

With the vb way, you just create a php file, and a new template, and they correspond to each other. I forgot that not everybody can view the codes, so this is it-

Quote
create a new file and name it whatever you want. in that file add:
<?php

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'test'); // change this depending on your filename

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array(

);

// get special data templates from the datastore
$specialtemplates = array(

);

// pre-cache templates used by all actions
$globaltemplates = array(
'TEST',
);

// pre-cache templates used by specific actions
$actiontemplates = array(

);

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

$navbits = array();
$navbits[$parent] = 'Test Page';

$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('TEST') . '");');

?>

Be sure to change 'TEST' to the actual template name, and change 'test' to
the filename. Also, change 'Test Page' to whatever you want to show in the
navbar, such as 'Viewing Member Profile' (just an example).

++++++++++++++++++++++++++++++++++++++++

create a new template and call it whatever your page is called above and add:

$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
<title>$vboptions[bbtitle]</title>
$headinclude
</head>
<body>
$header

$navbar

<table class="tborder" cellpadding="$stylevar[cellpadding]"
cellspacing="$stylevar[cellspacing]" border="0" width="100%"
align="center">
<tr>
<td class="tcat">Title</td>
</tr>
<tr>
<td class="alt1">Text</td>
</tr>
</table>

$footer
</body>
</html>

Could i basically do the exact same with SMF? I really want to switch back. I almost have him convinced, but we have to keep the field and store directory, the donate page, etc.
The only thing php can't do is tell you how much milk is left in the fridge.



[Unknown]

That's way more complicated than with SMF.  Here you go:

<?php$ssi_theme = 1;$ssi_layers = array('main');require_once('SSI.php');echo 'Hi!';ssi_shutdown();?>

Search for "ssi_layers" for more information.... most specifically, see this:

Integrating the forum into your site...

-[Unknown]

1MileCrash

#6
what exactly am i supposed to do with the code you posted? :-[

im still trying to figure out that file you posted dan....it's like a big essay, rather than a step by step. And it's trying to show me how to make a 404 page..
The only thing php can't do is tell you how much milk is left in the fridge.



[Unknown]

Quote from: Tippmaster on July 17, 2005, 08:44:25 PM
what exactly am i supposed to do with the code you posted? :-[

If you upload it to your site, and name it "hi.php", and go to it... you'll see "hi" in the layout of the forum.

See the "echo 'Hi!';" part?  That can be whatever you like.  You could replace it with:

?>
Something really, really long.
<?php


Which would work fine too.

-[Unknown]

1MileCrash

ahh! Wow, that is really simple. Thanks [Unknown]!

The only thing php can't do is tell you how much milk is left in the fridge.



Anihc

hmm I tried that and got this error

Warning: main(SSI.php): failed to open stream: No such file or directory in ...... on line 5

and this error

Fatal error: main(): Failed opening required 'SSI.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in ....... on line 5

.... was the path name starting prior to my public folder for my site /home/myusernameonmyhost/public_html/hi.php

1MileCrash

did you upload the file to the SMF directory?
The only thing php can't do is tell you how much milk is left in the fridge.



[Unknown]

You'll need to put a path to SSI.php if not.

-[Unknown]

Anihc

Oh I guess not, I thought since it was supposed to be for the website it needed to be in the main folder. I hate windows terms I prefer directory :) Ok I will test this again :)

bah Now I get this set of errors: (after moving this hi.php to the smf st
Warning: Cannot modify header information - headers already sent by (output started at /home/myusernameonmyhost/public_html/smf/Sources/Load.php(1040) : eval()'d code:490) in /home/myusernameonmyhost/public_html/smf/Sources/Subs.php on line 1704

Warning: Cannot modify header information - headers already sent by (output started at /home/myusernameonmyhost/public_html/smf/Sources/Load.php(1040) : eval()'d code:490) in /home/myusernameonmyhost/public_html/smf/Sources/Subs.php on line 1705

Thanks in advance ,
Anihc

Elissen

Make sure there are no spaces before <? or <?php and don't use echo's before the include. You can also place ob_start() before the include
<?phpob_start();$ssi_theme = 1;$ssi_layers = array('main');require_once('SSI.php');echo 'Hi!';ssi_shutdown();?>

[Unknown]

Quote from: Anihc on July 19, 2005, 01:51:45 AM
bah Now I get this set of errors: (after moving this hi.php to the smf st
Warning: Cannot modify header information - headers already sent by (output started at /home/myusernameonmyhost/public_html/smf/Sources/Load.php(1040) : eval()'d code:490) in /home/myusernameonmyhost/public_html/smf/Sources/Subs.php on line 1704

Warning: Cannot modify header information - headers already sent by (output started at /home/myusernameonmyhost/public_html/smf/Sources/Load.php(1040) : eval()'d code:490) in /home/myusernameonmyhost/public_html/smf/Sources/Subs.php on line 1705

Interesting.  For a better error message, run this query in phpMyAdmin or similar:

INSERT INTO smf_settings
   (variable, value)
VALUES ('disableTemplateEval', '1');

Be warned, this will also do away with the more helpful messages when there's a parse error.  What is phpMyAdmin?

-[Unknown]

Anihc

#15
Hmm I redid it again and I get what appears to be the top section of the website name and all in the current theme with the text hi. can be seen better here with all th graphics: http://www.monkeyblock.com/smf/hi.php Is this correct?

The MonkeyBlock 

Welcome, Guest. Please login or register.
July 19, 2005, 06:15:40 PM

   1 Hour 1 Day 1 Week 1 Month Forever
Login with username, password and session length 

Search:     Advanced search    You just got a new Forum complete with a new calander and NOW a new GALLERY!!! Comming up next? The webpage will have a new look along with an on the fly shoubox. 274 Posts in 116 Topics by 24 Members
Latest Member: Kroma 
         
Hi!

       
Page created in 0.031 seconds with 5 queries.

This was with using this code: (not the first section which keeps giving me errors)
<?php
ob_start();
$ssi_theme = 1;
$ssi_layers = array('main');
require_once('SSI.php');

echo 'Hi!';

ssi_shutdown();

?>

I will have to try the myphpadmin error check later this weekend. But is that what I should be getting then for the "webpage interface? basically the top section of what appears on the forum? Then just ad the html code below the php code?

Grudge

If that's what you wanted then yes - that's exactly how you do it :D
I'm only a half geek really...

Anihc

Ok great, that is a very slick way to do that! nice :)

Thanks,
Anihc

1MileCrash

that looks ALOT better than the vB way. Sweet.

The only thing php can't do is tell you how much milk is left in the fridge.



1MileCrash

now, when replacing "hi" with other text, i can use plain html...right?
The only thing php can't do is tell you how much milk is left in the fridge.



Advertisement: