News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Basic SSI FAQ

Started by Tomer, June 23, 2004, 05:06:24 AM

Previous topic - Next topic

Tomer

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 YOUR 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.
  • welcome.txt If your a guest, shows a login box, if not, a welcome message.

If this FAQ has helped you in any way please post in this thread your opinions of it, what was unclear, confusing...etc
Your feedback is very important to me. :)

Thanks

-Lamper

Owdy

Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

TodaysXt

I think it's helpful and want to read the advance section.  I had the bare min. on my page but now I know how to use the "if ($context['user']['is_guest'])," with this.
Thanks for your work
Xt.

TodaysXt

Tomer

Thanks, I will write the advanced soon.

Cypher7

Yea, great work.

I really wanted to use SSI, but hadn't a clue how to implement it...! And that FAQ was all I needed to get started!

Now I can go have some fun!  ;D

Tomer

Thanks a lot! :d Really means a lot of I helped someone.

Anyone got any hints on how to make it better, something that wasnt clear, confusing, anything?

Cypher7

Quote from: Lamper on June 23, 2004, 06:35:50 PM
Thanks a lot! :d Really means a lot of I helped someone.

Anyone got any hints on how to make it better, something that wasnt clear, confusing, anything?

nope, it was pretty clear to me! And I have NO clue about php!

only thing I could see was a typo  :P

QuoteThe 'i'f statments works on true and flase


Tomer

Fixed.

Check out the sample scripts attachched to the first post.

Cypher7

oooh, that welcome one is nice! and so simple!

I'll be using that one!!

Rpg Cyco

Great work Lamper, helped me a lot. :)

l8ter

Rpg Cyco

Tomer


Anguz

good work Lamper (^_^)

some may find it useful to know if they can restrict access to different areas depending on other membergroups other than Guest or Admin
Cristián Lávaque http://cristianlavaque.com

mcdougrs

VERY nice Basic Tutorial!! I can't WAIT for the Advanced version of it, especially if you could explain the array output method a little more in that one!!  :o

If someone could Sticky this I think that would be useful

Tomer

#13
Quote from: Anguz on June 24, 2004, 10:46:52 AM
good work Lamper (^_^)

some may find it useful to know if they can restrict access to different areas depending on other membergroups other than Guest or Admin

Expert SSI FAQ :)

Quote from: mcdougrs on June 24, 2004, 03:43:30 PM
VERY nice Basic Tutorial!! I can't WAIT for the Advanced version of it, especially if you could explain the array output method a little more in that one!!  :o

If someone could Sticky this I think that would be useful

Advanced SSI FAQ :)

Tomer

Here.


<?php

if ($context['user']['is_guest'])
   {
      echo 
''$txt['welcome_guest'], '';
   }
else
   {
      
ssi_welcome();
   }

?>

Cypher7

Cheers Lamper,

thanks to that and your FAQ's I now have some SSI on my main site airport-tkd.com!!

Nothing special, but I'm happy with it!

cheers!  :)

Jay K

Ben_S

Is your home page suppose to scroll 7 miles to the right?
Liverpool FC Forum with 14 million+ posts.

Cypher7

Darn, no, its not! Just checked it in Firefox... doesn't happen in IE is why I didnt notice it... I checked in firefox before I made some changes and it was fine...

tsk... and I dont have the time to go fix it... will have to wait a day or two! ah well!

Thanks for the heads up anyway...

Vinoth

fantastic work lamper/

1000 Beers to you.
Vinoth And Sachin ( SpecHackers Team )
The Best  Way to Help Poor Is not Becoming One Of Them.

Tomer

I prefer Root Beer, but thanks. :D

Advertisement: