Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New Coder
    Join Date
    Jan 2009
    Posts
    83
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Server Side Includes

    Trying to implement Server Side Includes into my site, I have a sidebar on every page and want to just edit one and every one will update. I think Example 2 on here is what I want to use, but how do I keep the same formatting so it looks the same?

    Site: www.baysidesuperior.org
    Sidebar Code:
    Code:
    <div id="search-news2">
    
    				<h2 class="downcast">Sermons</h2>
    
    				<div id="sermons">
                    <p><a href="javascript:november2909()">November 29, 2009</a></p>
                    
                    <p><a href="javascript:november2209()">November 22, 2009</a></p>
                    
                    <p><a href="javascript:november1509()">November 15, 2009</a></p>
    
    				  <p class="more"><a href="media">more</a></p>
    
    			  </div>
    	
    			  <h2 class="downcast">Upcoming Events</h2>
    
    				<div id="news">
                    
                    <p>Dec 04</p>
    				<h3><a href="events#E1">Senior Adults' Banquet</a></h3>
                    
                    <p>Dec 05</p>
    				<h3><a href="events#E2">Chancellors Concert</a></h3>
                    
                    <p>Dec 06</p>
    				<h3><a href="events#E3">Christmas Program</a></h3>
                    
                    <p>Dec 12</p>
    				<h3><a href="events#E4">White Elephant Party</a></h3>
                    
                    <p>Dec 24</p>
    				<h3><a href="events#E5">Christmas Eve Service</a></h3>
    				
                    </div>
    			</div>
    sidebar CSS:
    Code:
    #search-news {
    	float: right;
    	width: 208px;
    }
    
    #search-news div {
    	margin: 0;
    	padding-top: 3px;
    	padding-right: 0;
    	padding-bottom: 3px;
    	padding-left: 0;
    }
    
    #search-news2 {
    	float: right;
    	width: 140px;
    }
    
    #search-news2 div {
    	margin: 0;
    	padding-top: 3px;
    	padding-right: 0;
    	padding-bottom: 3px;
    	padding-left: 0;
    }
    
    #search-news2 #q {
    	width: 140px;
    	border: 1px solid #859D31;
    }
    
    #search-news2 .downcast {
    	background: #E6E7E7;
    	border-top: 1px solid #CFD0D0;
    	padding: 3px 4px 4px 4px;
    	margin: 2px 0 0 0;
    	font-weight: bold;
    }
    
    #search-news2 h3 {
    	background: url(images/bullet_letter.gif) no-repeat;
    	padding-left: 15px;
    	font-weight: bold;
    	margin-right: 0;
    	margin-bottom: .5em;
    	margin-left: 0;
    }
    
    #search-news2 p {
    	padding-left: 15px;
    	padding-right: 2px;
    	margin-top: 0.1em;
    	margin-right: 0;
    	margin-bottom: 0.1em;
    	margin-left: 0;
    	font-size: 10px;
    }
    
    #search-news div ul { float: left; }
    
    #search-news div li {
    	float: right;
    	border-bottom: 1px solid #e9e9e9;
    	width: 192px;
    	margin-top: 0;
    	margin-right: 0;
    	margin-bottom: 7px;
    	margin-left: 0;
    	padding-top: 0;
    	padding-right: 0;
    	padding-bottom: 6px;
    	padding-left: 0px;
    }
    
    #search-news div li a {
    	font-weight: bold;
    	text-transform: none;
    	display: block;
    	margin-top: -12px;
    	margin-right: 0;
    	margin-bottom: 0;
    	margin-left: 50px;
    }
    
    #search-news #q {
    	width: 140px;
    	border: 1px solid #859D31;
    }
    
    #search-news .downcast {
    	background: #E6E7E7;
    	border-top: 1px solid #CFD0D0;
    	padding: 3px 4px 4px 4px;
    	margin: 2px 0 0 0;
    	font-weight: bold;
    }
    
    #search-news h3 {
    	background: url(images/bullet_letter.gif) no-repeat;
    	padding-left: 15px;
    	font-weight: bold;
    	margin-right: 0;
    	margin-bottom: .5em;
    	margin-left: 0;
    }
    
    #search-news p {
    	padding-left: 15px;
    	padding-right: 2px;
    	margin-top: 0.1em;
    	margin-right: 0;
    	margin-bottom: 0.1em;
    	margin-left: 0;
    	font-size: 10px;
    }

  • #2
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Hello rickfink,
    All you need to change is the content of #search-news.

    It will be something like this, on all pages:
    Code:
    <div id="search-news">
    <?php include("sidebar.php"); ?>
    </div>
    Your sidebar php should read like this -
    Code:
    <h2 class="downcast">Sermons</h2>
    
    				<div id="sermons">
                    <p><a href="javascript:november2909()">November 29, 2009</a></p>
                    
                    <p><a href="javascript:november2209()">November 22, 2009</a></p>
                    
                    <p><a href="javascript:november1509()">November 15, 2009</a></p>
    
    				  <p class="more"><a href="media">more</a></p>
    
    			  </div>
    	
    			  <h2 class="downcast">Upcoming Events</h2>
    
    				<div id="news">
                    
                    <p>Dec 04</p>
    				<h3><a href="events#E1">Senior Adults' Banquet</a></h3>
                    
                    <p>Dec 05</p>
    				<h3><a href="events#E2">Chancellors Concert</a></h3>
                    
                    <p>Dec 06</p>
    				<h3><a href="events#E3">Christmas Program</a></h3>
                    
                    <p>Dec 12</p>
    				<h3><a href="events#E4">White Elephant Party</a></h3>
                    
                    <p>Dec 24</p>
    				<h3><a href="events#E5">Christmas Eve Service</a></h3>
    				
                    </div>
    And it will get it's styling from the CSS the same as it always did so it will look just like it does now.
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • Users who have thanked Excavator for this post:

    rickfink (12-09-2009)

  • #3
    New Coder
    Join Date
    Jan 2009
    Posts
    83
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Do I need to put anything else in the php file? Or just exactly what you put there. No other code in the beginning or anything?

    Just wondering because it didn't work for me

    www.baysidesuperior.org/events1
    Last edited by rickfink; 12-07-2009 at 07:37 PM.

  • #4
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    It looks like your events page still has an .hmtl extension.
    Any page that uses your include will need to be renamed with a .php extension.
    Also, just to make sure, you've verified your server is running php and it's available to you?

    Maybe this is an easier tutorial for building a php include.
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #5
    New Coder
    Join Date
    Dec 2009
    Posts
    11
    Thanks
    0
    Thanked 1 Time in 1 Post
    The messages above use php for includes. If you do not wish to use php, you can use a server side includes that does not require php. You can follow this tutorial to write your server side includes: http://wiki.lunarpages.com/Easier_Wa...tent_Using_SSI.

    This says you then need to save your files as shtml. However, you can have each html page parsed as shtml. This requires you to edit your htaccess file as shown in this tutorial. http://wiki.lunarpages.com/SSI_on_html_Web_Pages.

    Your included file need only have the text you want included. do not put in <head> tags, etc.

    This is just another way of doing it if you want to retain your pages with the .html extensions.

    Weaver

  • #6
    New Coder
    Join Date
    Jan 2009
    Posts
    83
    Thanks
    4
    Thanked 0 Times in 0 Posts
    I changed all the extensions to .php, works great now! Thanks!

  • #7
    New Coder
    Join Date
    Jan 2009
    Posts
    83
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Is there a performance hit when using this method?

    Doesn't seem like there is but because I have many pages I am using this method on my drop down menu, footer, and sidebar so just wondering.

  • #8
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    No its fine. Its the standard.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #9
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here is, in my opinion, the most interesting part:
    Sedebar Code:

    //If first time key in date run statement
    if(first == 0){
    ++first;//Track if is the first record key in
    items[i] = new Item(itemNumber, itemDesc, sellPrice, quantity);
    }
    //Else continue key in record
    else{
    entries = items[0].getEntries();//Get number of entries entered
    for(j=0; j<entries; ++j){

    duplicate = items[j].equals(itemNumber, itemDesc, sellPrice, quantity);//Check for duplication of entries

    if(duplicate == true) {
    Print.duplicateError();
    --i;
    --looping;
    break;
    }
    }
    if(duplicate == false)//else save record
    items[entries] = new Item(itemNumber, itemDesc, sellPrice, quantity);
    }
    __________________________
    Courtier conseil financement immobilier achat | Demande credit simulation plan de financement immobilier | Calcul pret projet financement immobilier travaux

  • #10
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    That "interesting part" crap is starting to become annoying.
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •