SSI FAQ Basic: Difference between revisions From Online Manual

Jump to: navigation, search
No edit summary
(Basic SSI FAQ)
Line 29: Line 29:
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:
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:


{{code|1=
{{code|1=<nowiki>
<?php
<?php
require("/home/simple/public_html/forum/SSI.php");  
require("/home/simple/public_html/forum/SSI.php");  
?>
?>
}}
</nowiki>}}
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.
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.


Line 43: Line 43:
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
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


{{code|1=
{{code|1=<nowiki>
ssi_menubar();
ssi_menubar();
}}
</nowiki>}}


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.
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.
Line 61: Line 61:
This is easy stuff to do, and I will show you how using PHP's 'if' statement:
This is easy stuff to do, and I will show you how using PHP's 'if' statement:


{{code|1=
{{code|1=<nowiki>
<?php
<?php
require("YOUR_PATH_TO_SSI.php");  
require("YOUR_PATH_TO_SSI.php");  
Line 78: Line 78:
  }
  }
?>
?>
}}
</nowiki>}}


I will explain the script I have written above:
I will explain the script I have written above:
Line 86: Line 86:
You can do the same thing but with admin
You can do the same thing but with admin


{{code|1=
{{code|1=<nowiki>
if ($context['allow_admin'])
if ($context['allow_admin'])
   {
   {
Line 95: Line 95:
   Block of statements
   Block of statements
   }
   }
}}
</nowiki>}}


----
----

Revision as of 14:32, 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 
   '<h5>Access Denied</h5>
   We are sorry guest, it seems you dont have premission to view these downloads.';
 }
else
 {
   echo
   '<h5>Welcome ', $context['user']['name'], '!</h5>
   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



Advertisement: