By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,564 Members | 1,081 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,564 IT Pros & Developers. It's quick & easy.

Default SSI help -->Creating a seperate Index page ?

P: 2
Just wanted to say hello to all the other newbies, and ask my first question:
Your help is extremely needed, and I would appreciate anyone who can help.

I am trying to make a website with SSI (server side includes), so my site doesn't take years to load.

Here is my html and <?php ?> function:

Expand|Select|Wrap|Line Numbers
  1. <body>
  2. <div id="container">
  3.  
  4. <?php include_once('includes/search.php');?>
  5. <?php include_once('includes/tabs.php');?>
  6. <?php include_once('includes/menu.php');?>
  7.  
  8.  
  9. <div id="content">
  10.  
  11.  
  12. <?php
  13.  
  14. include_once('includes/mission_statement.php');
  15.  
  16. include_once('includes/framed_gallery.php');
  17.  
  18. if($_GET['page'])
  19. {
  20.  
  21. include('pages/' . $_GET['page'] . '.php');
  22.  
  23. }
  24. else
  25. {
  26. include('pages/home.php');
  27. }
  28.  
  29.  
  30. ?>
  31.  
  32.  
  33. </div>
  34. <?php include_once('includes/footer.php');?>
  35.  
  36. </div>
  37.  
  38.  
  39. </body>
  40. </html>


Here is my menu:
Expand|Select|Wrap|Line Numbers
  1. <div id="side_bar_menu">
  2.  
  3.  
  4. <div class="glossymenu">
  5. <a class="menuitem_home" href="http://bytes.com/community/greenfield" ></a>
  6.  
  7. <a class="menuitem_about submenuheader" href"../greenfield/home.php?page=Welcome"> </a>
  8. <div class="submenu">
  9. <ul>
  10. <li><a href="http://bytes.com/community/greenfield/home.php?page=Welcome">Welcome</a></li>
  11. <li><a href="http://bytes.com/community/greenfield/home.php?page=Community">Our Community</a></li>
  12. <li><a href="http://bytes.com/community/greenfield/home.php?page=Common">Commom Experiences</a></li>
  13. <li><a href="http://bytes.com/community/greenfield/home.php?page=Expectations">Expectations of Students</a></li>
  14. </ul>
  15. </div>

What I don't understand is how I can get ONLY the index page to show these:

include_once('includes/mission_statement.php');

include_once('includes/framed_gallery.php');


with out it having to stay on every page there after...???

Thanks in advance,
Digital Drew
May 15 '09 #1
Share this Question
Share on Google+
4 Replies


Ciary
Expert 100+
P: 247
first of all, welcome on the forum.

/* second: php is a server side script. so all lines of php are processed by the server before it send the page to the browser, any lines of php (like include-once) aren't shown in the sourcecode. instead, your browser will still receive the full html code send by the server. so ssi isn't a way to make your page load faster. */

last: consider using code-tags in your posts on the forum. it makes your code easier to be read.

/*a tip: if you want to hide your code in sourcecode: use javascript/ajax to load your page. your html will still be visible in firebug though */

EDIT: srr i think i misunderstood your question:

try this:
Expand|Select|Wrap|Line Numbers
  1. if($_SERVER['PHP_SELF']=="index.php"){
  2.  
put it around the lines you only want to show on index.php
May 15 '09 #2

prabirchoudhury
100+
P: 162
1. you call all the different pages just frm the index.php page and stay there..

call your described pas as index.php page. make three part of ther page
a. header part : cinstant header part

b content part : would be dinamic body part and this part would call the different function according to request.

c. footer part: constant footer part



Expand|Select|Wrap|Line Numbers
  1. <HTML>
  2. <body>
  3. <!-- start header part -->
  4. <div id="container">
  5.  
  6. <?php include_once('includes/search.php');?>
  7. <?php include_once('includes/tabs.php');?>
  8. <?php include_once('includes/menu.php');?>
  9.  
  10. <!-- end header part -->
  11.  
  12.  
  13. <!-- start content part -->
  14. <div id="content">
  15.  
  16.  
  17. <?php
  18.  
  19. include_once('includes/mission_statement.php');
  20.  
  21. include_once('includes/framed_gallery.php');
  22.  
  23. if($_GET['page'])
  24. {
  25.  
  26. include('pages/' . $_GET['page'] . '.php');
  27.  
  28. }
  29. else
  30. {
  31. include('pages/home.php');
  32. }
  33.  
  34.  
  35. ?>
  36. </div>
  37. <!-- end content  part -->
  38. <!-- start footer part -->
  39. <?php include_once('includes/footer.php');?>
  40.  
  41. </div>
  42.  
  43.  
  44. </body>
  45. </html>
  46.  
  47.  
May 15 '09 #3

Markus
Expert 5K+
P: 6,050
For further reading, check out the MVC architecture (design pattern). Mixing your PHP (read: not server-side-includes) with your HTML (presentation) is generally a bad idea.
May 15 '09 #4

P: 2
Thanks to every one's prompt answers:
[b]Ciary:[b] Your edit was correct, and I'm going to try the
# if($_SERVER['PHP_SELF']=="index.php"){
tomorrow when I get a chance.

and

[b]Markus:[b] Thanks, I went to the MVC link you provided and I tried 2 frameworks before I stuck with CodeIgnitor, seems easy to follow and being more of a designer than a developer, it will absolutely work perfectly with my workflow in contrast to using simple PHP scripts here and there.

Thanks again!

DigitalDrew
May 16 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.