(Created page with "==Basic SSI FAQ== Hello and welcome to the Basic SSI FAQ, in this FAQ you will learn the basics of whats SSI, can it be used to my needs and how, this FAQ has commonly asked SSI...") |
No edit summary |
||
Line 106: | Line 106: | ||
*welcome.txt If your a guest, shows a login box, if not, a welcome message.[/li] | *welcome.txt If your a guest, shows a login box, if not, a welcome message.[/li] | ||
Copied from http://www.simplemachines.org/community/index.php?topic=12936.0 | |||
[[Category:Integrating SMF]] | |||
Revision as of 14:28, 7 June 2013
Basic SSI FAQ
Hello and welcome to the Basic SSI FAQ, in this FAQ you will learn the basics of whats SSI, can it be used to my needs and how, this FAQ has commonly asked SSI questions as well as tips and tricks, you will also find a list of attached scripts to the end of this post that may help you with what you have learned in this FAQ. If at the end you still have questions or comments, please post them. Your feedback if very imporant to me.
PLEASE DO NOT EDIT YOUR 'SSI.PHP' FILE Everything done here is done without having to edit 'SSI.php'
Whats SSI?
SSI - Server Side Includes, is a feature we use to help link our community board to the rest of our site, it also helps us take forum stats, news, announcements, recent posts...etc and view those things on other pages in our site.
How Can SSI Help me?
Even you can find use with SSI, lets take an example:
Example:
You have a site, and also a forum, and you want that when members are logged in, they will see a special downloads area on the downloads screen.
For something like this, SSI is needed and can be created in minutes
Fine SSI is good, how do I start using it?
The first thing you need to do is open a new file somewhere in your site, and give it a .php extention. Then open your text editer for that file and write this code:
<?php require("/home/simple/public_html/forum/SSI.php"); ?>
But make sure the path is the correct path for you to the 'SSI.php' file located in your forum directory, to see [b]YOUR[/b] correct path, check out the top part of 'ssi_examples.php' file located in your forum directory.
Ok I got the correct path to 'SSI.php', whats next?
Ok if you have got your correct path to SSI.php and written it in the file you created in the format I showed above, then good job. Next we will try to add features to your page [eg. menu bar, whos online list...etc]. Try this code between the 'require...' statement and the '?>' code
ssi_menubar();
Now try going to your page in your browser, if everything went well, you should see your menu bar from your forum, if you dont see anything there or some error message, that is probaly because you didnt write that correct path to your 'SSI.php' file. Well now that you got this working, you can go have fun with it, you can add many functions to your page, all the functions are listed in the 'ssi_examples.php' file located in your forum directory. [Also your correct 'SSI.php' path is listed in that file at the top]
That was cool, anymore?
Yes, there is more to SSI then the functions, now I will show you how the user premissions works with showing you how to write this example:
Example:
You have a site, and also a forum, and you want that when members are logged in, they will see a special downloads area on the downloads screen. This is easy stuff to do, and I will show you how using PHP's 'if' statement:
<?php require("YOUR_PATH_TO_SSI.php"); if ($context['user']['is_guest']) { echo 'Access Denied
We are sorry guest, it seems you dont have premission to view these downloads.'; } else { echo 'Welcome ', $context['user']['name'], '!
Here are your downloads:'; } ?>
I will explain the script I have written above: The 'if' statments works on true and flase, if the statement [In our case: ($context['user']['is_guest'])] is true, the first block is activated, and if false, the 'else' block is activated. So in our case, if you aren't logged in [You are a guest] you will see an access denied message, and if you are logged in, you will see the downloads area. You can use that in any way you wish.
You can do the same thing but with admin
if ($context['allow_admin']) { Block of statements } else { Block of statements }
Well this pretty much covers the basic Guide, the next guide is: 'Advanced SSI FAQ'.
Attached to the end of this post are some sample scripts that may help you out.
- membergroup.txt Put's your membergroup in a variable for later use.[/li]
- welcome.txt If your a guest, shows a login box, if not, a welcome message.[/li]
Copied from http://www.simplemachines.org/community/index.php?topic=12936.0