Latest Post
Tampilkan postingan dengan label CSS. Tampilkan semua postingan
Tampilkan postingan dengan label CSS. Tampilkan semua postingan

Live Weather Display Using CSS, jQuery and PHP

Written By Unknown on Kamis, 04 Oktober 2012 | 09.25

We set out with ambitious plans to have our website feature the live weather conditions using the geo location from anyone who looked at it. We wanted the time of day to be reflected depending on where they were based in the world, so somebody looking at the website in London, England would see a different style to someone looking at the website at the exact same time in San Diego, California. The goal was that people could see what the weather was like outside their window by looking at our website.


To read more about this article Click Here

Fancy Drop Down Menus Using CSS and JQuery

Written By Unknown on Rabu, 05 September 2012 | 09.25

I created a fancy drop down menus with CSS and JQuery. I used jQuery animate function and CSS to put some stylish effects. Also I used a background for navigation.  Support: Firefox, Chrome and Safari.


To read more about this article Click Here

For Demo Click Here

To download files Click Here

Fancy Ajax Tabs Navigation with Ajax CSS and PHP

Written By Unknown on Senin, 03 September 2012 | 10.24

This tutorial is one of my favorite because I like tutorials in which CSS work is much better. It is a simple ajax based tabs navigations and I hope you will like it. I used CSS3 to put some stylish look in it. You can change the size of frame or button size colors as you like.


To read more about this article Click Here

For Demo Click Here

To Download files Click Here

Create a Time Based CSS Style Sheet Switcher with jQuery

Written By Unknown on Rabu, 08 Agustus 2012 | 09.34

Style switchers have become a popular feature on websites these days. CSS style sheets allow a Web Designer to change the look and feel of a website with little effort. Some sites use “Day” and “Night” type of style switchers that automatically change the site theme based on the time of day.
 
This tutorial shows you how to create a time based CSS style sheet switcher using PHP that lets you change multiple style sheets at once at specific times of the day. There’s also a little bit of jQuery UI thrown in just for fun!

To read more about this article Click Here

For Demo Click Here

Click Here to download the source files


 



 

3D Gallery with CSS3 and jQuery

Written By Unknown on Rabu, 11 Juli 2012 | 09.06

With 3D transforms, we can make simple elements more interesting by setting them into three dimensional space. Together with CSS transitions, these elements can be moved in 3D space and create a realistic effect. Today, we want to share an experimental 3D gallery with you that uses CSS 3D transforms.


The main idea is to create a circular gallery where we have an image in the center and two on the sides. Since we are using perspective, the two lateral images will appear three dimensional when we rotate them.

To read more about this article Click Here

For Demo Click Here


 

Gravatar Login Box Design with jQuery, CSS and PHP

Written By Unknown on Senin, 09 Juli 2012 | 10.26

I had designed a simple interesting login box with contains Gravatar image, just importing user avatar from Gravatar.com based on email ID.  This post is very basic level CSS implementation and few lines of Jquery and PHP code. I hope this login box design  gives special flavor to to your web project. Before trying this live demo upload your avatar at Gravatar.


To read more about this article Click Here

For Demo Click Here



 

Stream Radio Script with jQuery ,CSS3 and PHP

Written By Unknown on Minggu, 03 Juni 2012 | 09.23

Today I have prepared another really great tutorial for you. Recently I have started development of my own radio software (as module for Dolphin CMS) and got interesting results. So, I would like to share you with some results about it. It will be nice looking (CSS3) radio script. It consists from three main elements: header (with nice animated search bar and integrated radio player), left side (with list of categories and subcategories) and right side (which will contains list of recent/ or filtered stations).


To read more about this article Click Here

For Demo Click Here



 

Create an online radio using jQuery and jPlayer

Written By Unknown on Selasa, 15 Mei 2012 | 08.49

Today, I’m glad to show you how you can use jQuery and the jPlayer plugin to build an online radio using JavaScript, PHP and a MySQL database.


To read more about this article Click Here




Photobooth with PHP, jQuery and CSS3

Written By Unknown on Senin, 07 Mei 2012 | 10.37

In this tutorial, we will be building a jQuery and PHP powered photobooth. It will allow your website visitors to take a snapshot with their web camera and upload it from a neat CSS3 interface.

The solution we are going to use for this app is webcam.js. It is a JavaScript wrapper around flash’s API that gives us control over the user’s webcam.


To read more about this article Click here

For Demo Click Here



Carbon Fiber Signup Form With PHP, jQuery and CSS3

Written By Unknown on Minggu, 22 April 2012 | 08.25

A carbon fiber – style form, build using progressive enhancement. This means that we first ensure that the form works well without JavaScript and fancy CSS support (think of IE6 here) and later move on by layering over cool styling, AJAX and jQuery magic.


To read more about this article Click Here

For Demo Click Here

Making a jQuery Page Flip Magazine with turn.js

Written By Unknown on Minggu, 15 April 2012 | 10.04

In this tutorial we are going to use PHP and the turn.js plugin, an implementation of the page flip effect with pure CSS3 and jQuery, to build a pretty magazine. We will fetch the most popular images from Instagram every hour, and use them as pages.
 
To read more about this article Click Here

For Demo Click Here 

 

Interactive Image Vamp up with jQuery, CSS3 and PHP

Written By Unknown on Senin, 26 Maret 2012 | 10.17

Today we will show you how to create an online application for giving some funny touches to an image. We will be using jQuery and jQuery UI for dragging and resizing little bling elements like mustaches and glasses. With PHP the image and the bling elements will get merged and the end result can be viewed.


To read more about this article Click Here

For Demo Click Here


Latest Post Blogroll Slider with jQuery and PHP

Written By Unknown on Kamis, 15 Maret 2012 | 10.17

In this tutorial we are going to create a blogroll slider that shows the latest post of your favorite blogs. We will be using jQuery, PHP and XSL. The aim is to get a given RSS feed of a blog and  parse the XML data with the help of PHP. We will apply XSL to transform the feed into HTML and cache the result for subsequent use. We will be using a lot of CSS3 properties for a polished look.


To Knoe more about this article Click Here

For Demo Click Here

6 CSS3 and jQuery Loading Animations Solutions

Written By Unknown on Rabu, 18 Januari 2012 | 09.07


The largest resource of CSS3 and jQuery Loading animations is now in your hands. You will be surprised to see the amazing animated series as we bring for you the best of the run. Before loading animation was tough and was restricted only to the Gif format but now with powerful technologies and browsers (the canvas and VML), you can also load it with the CSS3 and jQuery . It is highly customizable and the server gives you a smooth processing of the request made by you.


There is a total of about CSS3 and jQuery which can load animation but not all of them can work in the older browsers. The JavaScript VML and canvas is supported by spin.js and activity indicator. jQuery plugin  renders spinner using VML or SVG. 

It has the same functionalities with spin .js other than relying on jQuery. The script is light weight with alpha transparency, high configuration and is resolution independent. Moreover it works in major browsers and has feature detection possibilities.

The canvas loader plugin is useful and better than the typical gif loading animation. The loader is canvas based and has the same width and height. This plugin is useful for developing the mobile apps to be seen on Android. It lets you check the canvas support before replacement. We have Heartcode CanvasLoader using the HTML5 Canvas to customize circular preloaders. 

This is from the JavaScript UI library. Spin.js supports old browsers and has an UI for customizing your preloader. It has high configuration, supporting the major browsers and is independent of resolution. Spin.js uses VML as an emergency in the old IEs. The Sonic Looping Loader is a JavaScript preloader and helps you create custom loading series of animations. 

The looping animations works best with it. The only thing is that your browser should support canvas. Other than this the file size is small with ~3k minified and is highly configurable.

Ajax load is quite handy and is used for standard animation loading. You can create your desired icons with it by selecting your type of indicator and changing the background and foreground code color. Drop down menu is another solution in the navigation menu with JavaScript. You can also control cookie using JavaScript. 

Chimply gives you some useful animated circles and it has generated about 18131 images for you. You can get the three dimensional category of circular, horizontal, rectangular, smiley, religion signs and zodiac signs.


CSS3 and jQuery Loading Animations

spin.js


CSS3 Loading Animation Loop


CSS3 Loading Animation


CanvasLoader Creator

CSS Loading Animation Circle Style
Loading CSS spinners and bars generator for AJAX & JQuery


Force a vertical scroll bar in non-IE browsers to avoid page jump

Written By Unknown on Minggu, 27 November 2011 | 08.49

Webpages that don’t fit vertically in the browser window have a vertical scroll bar, pages that do fit in the browser window don’t have this scroll bar. All is great until you click from a short page to a tall page and the content ‘jumps’, in order to make room for the scroll bar.


If you’re a developer you’re used to this and probably don’t even notice it. I’ve had multiple clients ask me why the page jumps and have had to explain the reasoning, just to hear “oooh that’s weeeird, isn’t it???”

No, I just explained it. Anyway, to avoid this conversation, add the following CSS to your style sheet. This code forces the vertical scroll bar, and voila, no more page jumps or calls from the client.

html { overflow-y: scroll }
 
 

Create a fading magnifying glass overlay on image hover with jQuery and CSS3

Written By Unknown on Selasa, 04 Oktober 2011 | 11.13

A common method for setting up a quick image gallery on a website is to have small thumnbnail images which when clicked on pop open larger versions of the image (using a script like Fancybox). It’s a good idea to have some sort of effect on the smaller thumbnail images when they are hovered over to make it more user friendly (in the same way you might change the color of a text link when hovered over).


One simple method is to put a colored border around the image with CSS and change the color of the border when hovered over. Another more exciting option is to apply a background shadow behind the image with CSS3 when hovered over. I’ve used both of these methods on multiple websites, but wanted a more exciting solution.


The Idea

What I decided to create was a transparent image overlay when hovered on. So when you hover over the image you would see a magnifying glass icon over a transparent black background. This would make it easy for the user to see where they are on the page. Another reason this method is better than simply changing the border color is that the magnifying glass gives an indication that the image will zoom in or expand when clicked on. I’ve create two ways of accomplishing this effect, one used jQuery, and the other uses only CSS3.

The Solution



Both methods use similar techniques, the only difference is weather they use jQuery or CSS for fading the opcaity. There is an image wrapped in a link. Inside of this link there is a span element. By setting the span to dispaly block, setting the width and height of the span, and setting a higher z-index than the image; the span element covers the image. 

By setting the background image and color the span element hides the original image. Setting the opacity to zero on the span element allows the thumbnail image to be seen. To create the overlay effect we simply change the opacity of the span element to 70% (or whatever you want to use for your project). One method uses jQuery to apply this opacity, the other method uses CSS3 transitions and opacity settings.



jQuery Method

The jQuery method is cross browser safe, and unlike the CSS3 method fades the magnifying glass both in AND out. This method uses jQuery to set the opacity of the span element when hovered over. Here is the HTML for this method:

<a class="image" href="#">
<span class="roll" ></span>
<img class="imgborder" alt="" src="images/pic.jpg">
</a>
 
Here is the CSS for this method:
 
span.roll {
background:url(images/mag.png) center center no-repeat #000;
height: 346px; position: absolute; width: 347px;
-moz-box-sh
z-index: 10; -webkit-box-shadow: 0px 0px 4px #000 ;adow: 0px 0px 4px #000; box-shadow: 0px 0px 4px #000;
}
And the jQuery:
 
$(function() {
// OPACITY OF BUTTON SET TO 0%
$(".roll").css("opacity","0");
er(function () {
// ON MOUSE OVER $(".roll").ho v // SET OPACITY TO 70%
opacity: .7 }, "slow");
$(this).stop().animate( { }, // ON MOUSE OUT function () {
stop().animate({ opacity:
// SET OPACITY BACK TO 50% $(this) .0 }, "slow"); });
});

CSS3 Method

With the increasing support for CSS3 in modern browsers I just had to try this method using CSS3 opacity and transitions. Here’s the HTML for the CSS (no javascript used) method:
<a class="image"  href="#">
<span class="rollover" ></span>
<img class="imgborder" alt="" src="images/pic2.jpg">
</a>
Here’s the CSS, where all the magic happens:
 
span.rollover {
opacity: 1;
n-duration: 1s; -moz-transi
-o-transiti otion-duration: 1s;
-webkit-transform 1s; background:url(ima
-webkit-transition :ges/mag.png) center center no-repeat #000; cursor: pointer;
10; opacity: 0
height: 346px; width: 347px; position: absolute; z-index: ; } span.rollover:hover { opacity: .7; -o-transition-duration: 1s;
1s; -webkit-box-shadow: 0px 0
-moz-transition-duration: 1s; -webkit-transition: -webkit-transform px 4px #000; -moz-box-shadow: 0px 0px 4px #000; box-shadow: 0px 0px 4px #000;
}

Create a PHP Website Template from Scratch

Written By Unknown on Jumat, 08 Juli 2011 | 11.29

This is a tutorial on creating a PHP website template starting with HTML and CSS. We will start with the basics and you can also download the final product. Please remember that I am using very basic CSS styling in this example just for you to get the idea, and not so much to make it look pretty. The download will contain both the styled example as well as a complete blank template that you can use for your own starting point for any project personal or commercial. The demo files are released under GPL V2.


Setting up the File structure and Folders

Step One

Let’s start by creating a new folder. I have named this folder php_site

Inside of this folder we are now going to create two new files. One is index.html and the other file is going to be named style.css

Step Two

Now we are going to create two more folders inside of our main folder. The first folder is going to be named includes, and the second folder will be named variables.

We should now have a setup that looks like the following:


Step Three

Now, using your favorite html editor open the index.html file. We are going to to create a basic html website document. This is the code I am using:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="author" content="" />
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
<title>Advanced PHP Tutorial PHP Template</title>
</head>
<body>
<div id="wrapper">
<div id="header">
</div> 
<!-- end #header -->
<div id="nav"></div> 
<!-- end #nav -->

<div id="content"></div> 
<!-- end #content -->

<div id="sidebar"></div> 
<!-- end #sidebar -->

<div id="footer"></div> 
<!-- end #footer -->

</div> 
<!-- End #wrapper -->
</body>
</html>

Step Four

Now I am going to open up the style.css file and add the divs we will be using. I have added very basic styling so you can see the site and get the idea of what we are doing. Remember that you can use your own styling when creating your website to suit your needs.


This is the CSS I am adding to the stylesheet:

body 
{
background-color:#f1f1f1;
font-family: georgia,sans-serif;
color:#333;
margin:0;
padding:0;
}

#wrapper 
{
width:960px;
background-color:#f8f8f8;
margin:0 auto;
border-left:1px solid #ccc;
border-right:1px solid #ccc;
}

#header 
{
width:960px;
height:135px;
margin:0 auto;
margin-bottom:25px;
border-bottom:1px solid #ccc;
border-top:1px solid #ccc;
}

#header h2 
{
padding:10px;
}

#nav 
{
width:960px;
height:40px;
border-bottom:1px solid #ccc;
}

#nav a 
{
display:inline;
padding:10px;
text-decoration:none;
background-color:#f1f1f1;
}

#nav a:hover 
{
background-color:#bababa;
height:80px;
}

#content 
{
width:675px;
float:left;
padding:10px;
}

#sidebar 
{
width:200px;
float:right;
margin-bottom:25px;
}

#sidebar a 
{
text-decoration:none;
}

#sidebar li 
{
list-style:none;
}

#footer 
{
clear:both;
width:960px;
height:135px;
border-top:1px solid #ccc;
}

#footer p 
{
padding:10px;
}

Step Five

Next we will create some more files that we will be using when we start converting our template to php.

Open up the folder we created inside of our main folder called variables. Next, create a blank file called variables.php


Then go into the other folder we created called includes and create the following files:
  • header.php
  • nav.php
  • sidebar.php
  • footer.php

Step Six

Now we will need to add some content to our index.html file. I have filled in the header area with an H2 tag for the website header title. I will also be adding the links in the nav area, as well as some text in the content area, sidebar, and footer. The final index.html file now looks like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="author" content="" />
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
<title>Advanced PHP Tutorial PHP Template</title>
</head>
<body>
     <div id="wrapper">
<div id="header">
 <h2>Advanced PHP Tutorial PHP Template</h2>
</div> <!-- end #header -->
<div id="nav">
<a href="#">Home</a>
<a href="#">About</a>
<a href="#">Portfolio</a>
<a href="#">Contact</a>
</div> <!-- end #nav -->

<div id="content">
<h1>Heading1</h1>
<h2>Heading2</h2>
<h3>Heading3</h3>
<h4>Heading4</h4>
<h5>Heading5</h5>
<h3>Paragraph Element</h3>
<p>
Quisque pellentesque sodales aliquam. Morbi mollis neque eget arcu egestas non ultrices neque volutpat. 
</p>
<p>
Quisque pellentesque sodales aliquam. Morbi mollis neque eget arcu egestas non ultrices neque volutpat. 
</p>
<h3>Another Heading Starting Point</h3>
<p>
Quisque pellentesque sodales aliquam. Morbi mollis neque eget arcu egestas non ultrices neque volutpat. 
</p>
<p>
Quisque pellentesque sodales aliquam. Morbi mollis neque eget arcu egestas non ultrices neque volutpat.
</p>
</div> <!-- end #content -->

<div id="sidebar">
<h3>Navigation</h3>
  <li><a href="#">Home</a></li>
  <li><a href="#">About Us</a></li>
  <li><a href="#">Links</a></li>
  <li><a href="#">Portfolio</a></li>
  <li><a href="#">Contact</a></li>
<h3>Box Two</h3>
 <li><a href="#">Link Here</a></li>
 <li><a href="#">Link Here</a></li>
 <li><a href="#">Link Here</a></li>
 <li><a href="#">Link Here</a></li>
 <li><a href="#">Link Here</a></li>
<h3>Box Three</h3>
 <li><a href="#">Link Here</a></li>
 <li><a href="#">Link Here</a></li>
 <li><a href="#">Link Here</a></li>
 <li><a href="#">Link Here</a></li>
 <li><a href="#">Link Here</a></li>
</div> <!-- end #sidebar -->

<div id="footer">
 <p>Copyright &copy 2010 <a href="http://www.id-script.com/">Advanced PHP Tutorial PHP Template</a></p>
</div> <!-- end #footer -->
     </div> <!-- End #wrapper -->
 </body>
</html>

Step Seven

Now we will start converting our template to PHP. We will need to take a brief look at the html code we have and decide which areas will be sliced. We will be removing specific areas from the index.html file and placing them into the php files we have created inside the includes folder.

Let’s start with the top of the html document on the header. Copy the header div and cut it from the document. Then open your includes folder, and the header.php file we created and add the code to the header.php.

header.php

<div id="header">
  <h2>Advanced PHP Tutorial PHP Template</h2>
</div> <!-- end #header -->

Make sure this area has now been removed completely from the index.html file and placed into the header.php file. In place of this code, we will now add the following to the index.html file.

<?php include('includes/header.php'); ?>


Now our index.html should look like this: (Make a note that the header area has now been replaced with our php include function that is calling our external header.php file).

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="author" content="" />
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
<title>Advanced PHP Tutorial PHP Template</title>
</head>
 <body>
     <div id="wrapper">
<?php include('includes/header.php'); ?>
<div id="nav">
  <a href="#">Home</a>
  <a href="#">About</a>
  <a href="#">Portfolio</a>
  <a href="#">Contact</a>
</div> <!-- end #nav -->

<div id="content">
<h1>Heading1</h1>
<h2>Heading2</h2>
<h3>Heading3</h3>
<h4>Heading4</h4>
<h5>Heading5</h5>
<h3>Paragraph Element</h3>
<p>
Quisque pellentesque sodales aliquam. Morbi mollis neque eget arcu egestas non ultrices neque volutpat.
</p>
<p>
Quisque pellentesque sodales aliquam. Morbi mollis neque eget arcu egestas non ultrices neque volutpat. 
</p>
<h3>Another Heading Starting Point</h3>
<p>
Quisque pellentesque sodales aliquam. Morbi mollis neque eget arcu egestas non ultrices neque volutpat. 
</p>
<p>
Quisque pellentesque sodales aliquam. Morbi mollis neque eget arcu egestas non ultrices neque volutpat. 
</p>
</div> <!-- end #content -->

<div id="sidebar">
<h3>Navigation</h3>
  <li><a href="#">Home</a></li>
  <li><a href="#">About Us</a></li>
  <li><a href="#">Links</a></li>
  <li><a href="#">Portfolio</a></li>
  <li><a href="#">Contact</a></li>
<h3>Box Two</h3>
  <li><a href="#">Link Here</a></li>
  <li><a href="#">Link Here</a></li>
  <li><a href="#">Link Here</a></li>
  <li><a href="#">Link Here</a></li>
  <li><a href="#">Link Here</a></li>
<h3>Box Three</h3>
  <li><a href="#">Link Here</a></li>
  <li><a href="#">Link Here</a></li>
  <li><a href="#">Link Here</a></li>
  <li><a href="#">Link Here</a></li>
  <li><a href="#">Link Here</a></li>
</div> <!-- end #sidebar -->

<div id="footer">
 <p>Copyright &copy 2010 <a href="#">Website Name</a></p>
</div> <!-- end #footer -->
     </div> <!-- End #wrapper -->
 </body>
</html>

Step Eight

Now we will continue to slice the html document and place the code in the proper php files we made.

Next let’s move to the nav div. The same as above, we are going to copy and cut that piece of code and place it into our nav.php file that is located inside of the includes folder.

This is what we are adding to the nav.php file:

<div id="nav">
  <a href="#">Home</a>
  <a href="#">About</a>
  <a href="#">Portfolio</a>
  <a href="#">Contact</a>
</div> <!-- end #nav -->


Again we will replace the code removed from the html document with the following:

<?php include(includes/nav.php); ?>

Step Nine

Now it is time to do the sidebar. Copy and cut the sidebar div and place it into the sidebar.php file we created that is located inside the includes folder.

This is the code we are adding:

sidebar.php

<div id="sidebar">
<h3>Navigation</h3>
  <li><a href="#">Home</a></li>
  <li><a href="#">About Us</a></li>
  <li><a href="#">Links</a></li>
  <li><a href="#">Portfolio</a></li>
  <li><a href="#">Contact</a></li>
<h3>Box Two</h3>
  <li><a href="#">Link Here</a></li>
  <li><a href="#">Link Here</a></li>
  <li><a href="#">Link Here</a></li>
  <li><a href="#">Link Here</a></li>
  <li><a href="#">Link Here</a></li>
<h3>Box Three</h3>
 <li><a href="#">Link Here</a></li>
 <li><a href="#">Link Here</a></li>
 <li><a href="#">Link Here</a></li>
 <li><a href="#">Link Here</a></li>
 <li><a href="#">Link Here</a></li>
</div> <!-- end #sidebar -->

We will again do the same thing for the footer area. Copy and cut the footer div and place it into the footer.php file we created in the same includes folder.

Here is the footer.php code:

<div id="footer">
   <p>Copyright &copy 2010 <a href="#">Website Name</a></p>
</div> <!-- end #footer -->


Step Ten

Now that our index.html is properly sliced, we can rename the index.html file to index.php

Now that we have created this template, as long as the php includes are on any page we only have to modify the one single file to make it visible accross your entire website. This again is good for anyone with a lot of content and pages. Instead of having to edit the sidebar on every page of your site you can now just edit the sidebar.php file and it will reflect on all of your pages. This makes it a lot easier to keep up with large portions of website material.

Our folder should now look like this:


Creating PHP Variables for the template

Now we will make it a little more dynamic and even easier to be able to modify when needed. Lets take a look at the header.php file inside the includes folder.

<div id="header">
    <h2>Advanced PHP Tutorial PHP Template</h2>
</div> <!-- end #header -->


We are going to modify this a little bit to change the H2 heading from a different file using a variable. Creating a variable is good for areas on your website that may change more than others. It may also be a good way to allow clients to edit a single file to change certain items on their website.

Now let’s replace the text within the H2 heading to this:

<h2><?php echo $heading ?></h2>

Now our header.php file will look like this: Notice we placed the echo php command within the H2 brackets. This will give our variable output the H2 heading we want.

<div id="header">
    <h2><?php echo $heading ?></h2>
</div> <!-- end #header -->

Next we are going to open up the file inside of the variables folder that we created named variables.php

We will add the variable that we are going to echo on the website heading. I have named this variable heading.

variables.php


<?php
$heading='Advanced PHP Tutorial PHP Template';
?>

Now, at any time we want to change what is titled on the heading of our template, we can simply open our variables.php file and modify what is between the quotes. This will always be the output on our header.php file where we placed the echo command.

One step Further

Now we will do the same thing to our footer.php file. Open the footer.php that we have in our includes folder and let’s take a look at it:

<div id="footer">
    <p>Copyright &copy 2011 <a href="#">Website Name</a></p>
</div> <!-- end #footer -->

Let’s change this like we did the header file, and add a variable to use.

We will place our echo command within the paragraph brackets. You should now have the following in your footer.php:

<div id="footer">
    <p><?php echo $footer ?></p>
</div> <!-- end #footer -->

And again we will visit our variables.php file located in the variables folder we made and we will now update it with our new variable. The final should now look like this:

variables.php

<?php
$heading='Advanced PHP Tutorial PHP Template';
$footer='Copyright &copy; 2010 Advanced PHP Tutorial PHP Template';
?>

Make note of the above. When using PHP variables we cannot use a regular quote. They should be replaced as you see above directly after the a href=

This is to ensure the code is read properly by browsers. If you use a regular quote it will not work.

Making it all work

The last thing we need to do in order to make our variables work is to do one last php include within our template to call the variables file.

Let’s open up our header.php file and add the following:

<?php include('variables/variables.php'); ?>

This will tell our template to use the variables file we have created.
The header.php file should now look like this:
<?php include('variables/variables.php'); ?>
<div id="header">
    <h2><?php echo $heading ?></h2>
</div> <!-- end #header -->

Next we will need to do the same to our footer.php file. Add the same include at the top. The footer.php should now look like this:

<?php include('variables/variables.php'); ?> 
<div id="footer"> 
 <p><?php echo $footer ?></p> 
</div> 
<!-- end #footer -->


Now that these two files are calling the variables, you will see the reflected results in the final template. You can always create new variables, and create any type of php files you want. You can even change the folder directory in any way you wish as long as your php include function displays the correct path to the files.

Playing with the PHP template

To test it a bit further let’s duplicate the index.html file and make a second page that will also call the external php files. This way we will be able to see more exactly how this works.

Make a copy of your index.php file and rename the new file to about.php

Inside of this file you can change anything you want within the #content div inside of the website #wrapper

I have created the following for testing purposes:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="author" content="" />
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
<title>Advanced PHP Tutorial PHP Template About Page</title>
</head>
 <body>
     <div id="wrapper">
<?php include('includes/header.php'); ?>
<?php include('includes/nav.php'); ?>
<div id="content">
<h3>About Me Page</h3>
<p>
Quisque pellentesque sodales aliquam. Morbi mollis neque eget arcu egestas non ultrices neque volutpat. 
</p>
<p>
Quisque pellentesque sodales aliquam. Morbi mollis neque eget arcu egestas non ultrices neque volutpat. 
</p>
<h3>Another Heading Starting Point</h3>
<p>
Quisque pellentesque sodales aliquam. Morbi mollis neque eget arcu egestas non ultrices neque volutpat. 
</p>
<p>
Quisque pellentesque sodales aliquam. Morbi mollis neque eget arcu egestas non ultrices neque volutpat.
</p>
<h3>Notice The Include Files</h3>
<p>
Quisque pellentesque sodales aliquam. Morbi mollis neque eget arcu egestas non ultrices neque volutpat.
</p>
<h3>Another Heading Starting Point</h3>
<p>
Quisque pellentesque sodales aliquam. Morbi mollis neque eget arcu egestas non ultrices neque volutpat.
</p>
<p>
Quisque pellentesque sodales aliquam. Morbi mollis neque eget arcu egestas non ultrices neque volutpat.
</p>
</div> <!-- end #content -->
<?php include('includes/sidebar.php'); ?>
<?php include('includes/footer.php'); ?>
     </div> <!-- End #wrapper -->
 </body>
</html>

Now make sure that we go inside of our nav.php file as well as the sidebar.php file and link the new page we have just created. Again using your html editor of choice, first open up your nav.php file.

Updating the links should make your file now look like this example below:

nav.php

<div id="nav">
   <a href="index.php">Home</a>
   <a href="about.php">About</a>
   <a href="#">Portfolio</a>
   <a href="#">Contact</a>
</div> <!-- end #nav -->

Next we will need to do the same thing to our sidebar.php file to make sure the links now work.

sidebar.php


div id="sidebar">
<h3>Navigation</h3>
 <li><a href="index.php">Home</a></li>
 <li><a href="about.php">About Us</a></li>
 <li><a href="#">Links</a></li>
 <li><a href="#">Portfolio</a></li>
 <li><a href="#">Contact</a></li>
<h3>Box Two</h3>
  <li><a href="#">Link Here</a></li>
  <li><a href="#">Link Here</a></li>
  <li><a href="#">Link Here</a></li>
  <li><a href="#">Link Here</a></li>
  <li><a href="#">Link Here</a></li>
<h3>Box Three</h3>
  <li><a href="#">Link Here</a></li>
  <li><a href="#">Link Here</a></li>
  <li><a href="#">Link Here</a></li>
  <li><a href="#">Link Here</a></li>
  <li><a href="#">Link Here</a></li>
</div> <!-- end #sidebar -->

Now we are complete. We have created a two page PHP website template that we can expand on more to make a completed project. We have learned how to use basic php includes and variables to be able to edit content accross many different pages at one time. I really hope you have enjoyed this post and learned something from it as well.

Just to take a final look at the new file structure with the added page you can view the image below for reference:


This tutorial was created to give you some basic knowledge on php and creating a php website template.

If you have any questions I will do my best to answer them in the comments below.
 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Kumpulan Kata Broadcast Blackberry - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger