SSI FAQ Basic: Difference between revisions From Online Manual

Jump to: navigation, search
(Basic SSI FAQ)
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
==Basic SSI FAQ==
==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.
Hello and welcome to the Basic SSI FAQ. In this FAQ, you will learn the basics of whats SSI, whether it can be used to your needs and how. This FAQ has commonly asked SSI questions as well as tips and tricks.
Your feedback if very imporant to me.


'''PLEASE DO NOT EDIT YOUR 'SSI.PHP' FILE
'''PLEASE DO NOT EDIT YOUR 'SSI.PHP' FILE
Everything done here is done without having to edit 'SSI.php''''
Everything done here is done without having to edit 'SSI.php''''


===Whats SSI?===
===What's 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.
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.
Line 19: Line 18:
'''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.
You have a site, and also a forum, and you want logged in members to see a special downloads area on the downloads screen.


For something like this, SSI is needed and can be created in minutes
For something like this, SSI is needed and can be created in minutes
Line 41: Line 40:


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.  
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
Next we will try to add features to your page [eg. menu bar, who's online list...etc]. Try this code between the 'require...' statement and the '?>' code


{{code|1=<nowiki>
{{code|1=<nowiki>
Line 52: Line 51:
----
----


===That was cool, anymore?===
===That was cool, any more?===


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:
Yes, there is more to SSI than the functions. Now, I will show you how the user permissions work by showing you how to write this example:


'''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.
You have a site, and also a forum, and you want logged in members to 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:
This is easy stuff to do, and I will show you how using PHP's 'if' statement:


Line 69: Line 68:
   echo  
   echo  
   '<h5>Access Denied</h5>
   '<h5>Access Denied</h5>
   We are sorry guest, it seems you dont have premission to view these downloads.';
   We are sorry guest, it seems you dont have permission to view these downloads.';
  }
  }
else
else
Line 81: Line 80:


I will explain the script I have written above:
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.
The 'if' statements 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.
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.


Line 101: Line 100:
Well this pretty much covers the basic Guide, the next guide is: '[[SSI_FAQ_Advanced|Advanced SSI FAQ]]'.
Well this pretty much covers the basic Guide, the next guide is: '[[SSI_FAQ_Advanced|Advanced SSI FAQ]]'.


Attached to the end of this post are some sample scripts that may help you out.
Attached to the end of [[http://www.simplemachines.org/community/index.php?topic=12936.0 this post]] are some sample scripts that may help you out.


*membergroup.txt Put's your membergroup in a variable for later use.[/li]
*membergroup.txt Put's your membergroup in a variable for later use.
*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.


Copied from http://www.simplemachines.org/community/index.php?topic=12936.0
Copied from http://www.simplemachines.org/community/index.php?topic=12936.0


[[Category:Developing SMF]]
[[Category:Integrating SMF]]
[[Category:Integrating SMF]]
[[Category:SSI]]

Latest revision as of 00:24, 5 August 2015

Basic SSI FAQ

Hello and welcome to the Basic SSI FAQ. In this FAQ, you will learn the basics of whats SSI, whether it can be used to your needs and how. This FAQ has commonly asked SSI questions as well as tips and tricks.

PLEASE DO NOT EDIT YOUR 'SSI.PHP' FILE Everything done here is done without having to edit 'SSI.php'

What's 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 logged in members to 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, who's 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, any more?

Yes, there is more to SSI than the functions. Now, I will show you how the user permissions work by showing you how to write this example:

Example:

You have a site, and also a forum, and you want logged in members to 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 permission 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' statements 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.
  • welcome.txt If your a guest, shows a login box, if not, a welcome message.

Copied from http://www.simplemachines.org/community/index.php?topic=12936.0



Advertisement: