Tutorials

Building a basic PHP E-Commerce Application using CodeIgniter Framework – Part 3

Mar 10, 2009 insic 58 Comments

Part III – Creating the site mockup and Preparing our View.

In this part of the series we will create a design mockup for our e-commerce site. And create a reusable component of our view.

First we need to know how our site should looks like. And how we showcase our products. Basically our site should have a navigation menu, a header with a logo, a content body, a footer, and a search form.

In our homepage we need to show some of our products and put a featured product area where we can show three or more items, a main menu for our ‘home’, ‘about’, ‘contact us’ and other necessary page we need later as we go on this tutorial, and a side navigation menu for our product categories.

Take a look the site mockup I have created.

Creating the Mockup Template.

We need to create a folder where we put our files needed in making the template such as the css, images, and JavaScripts files. Now, go to the root of your CI installation then create a folder and name it as you like, in this tutorial we name it ‘public’ then inside the public folder we need to create the following folders ‘css, ‘images’, ‘js’, and ‘products’ folder for the images of our products and a ‘thumb’ folder inside our products folder for the product thumbnails.

Directory structure we have just created.

Open system/application/views folder, create a new file named it to template.php, open it in your text editor then populate the code below. Or you can go download my code here.

If you noticed there are three include files for our template first the default.css and the two javascript file, the jQuery and the s3slider.js. I am using the s3slider Plugin. We will be using this javascripts to showcase our featured products. This files are also included in the downloads.

Lets create our css file, open public/css folder and create a new file named it to default.css then populate the css code below.

Images used in stylesheet is also included in the download file. Stylesheet quite long. Coz i already included all the css styles we will be using for the entire tutorial.

For us to preview our template.php, we need to load it in our controller. Create a test controller, you can name it anything you want. For example lets create a ‘testView’ controller open system/application/controllers create a new file testview.php then populate the sample code below.

As you can see we load the url helper in this controller because if you have noticed in our template. We have this line <base href="<?= base_url(); ?>" />. This simply return the base url of our applications installation as what we set in in part 1 of this tutorial.

Now open your browser and type the url http://localhost/tutorial/testview/ . You must now see our template in action. See the online demo here.

Creating our View File

My style in creating a view in codeIgniter is having a master template then include those files that are frequently change or updated during page transitions.

Out of our mockup template above we create a master template of our view. We take those part which can be reused in the entire site like the header, menu, side menu and the footer. This technique is really common in developing a PHP application.

Here we only have to prepare our view files for the next part of the tutorial. Open system/application/views folder, create a new file and we name it home_view.php, open it in a text editor and then populate the code below.

Our master view template is now ready. As you can see, its merely an html with one line of php code (<?php $this->load->view($template); ?>) that calls our page template view file which we will be adding soon as we go on in developing our application.

The next part of this tutorial, we will be making use of our template just made. We have to make our site’s hompage work dynamically. The product feature slideshow must be dynamically generated in our application.

About the author: insic

Subscribe in my RSS Feed for more updates on Web Design and Development related articles. Follow me on twitter or drop a message to my inbox.

  • http://www.pushingbuttons.net Timothy

    The mockup looks really good! Very clean and user-friendly.

    This e-commerce tutorial is great. Good work.

  • Henry

    The demo looks great! Awesome Tutorial. Looking forward for the next part.

  • http://www.lukasfiala.com Lukas

    Really nice and clean template. 

  • Eduardo

    the parser library is very cool!

  • Steven

    Thanks for the great tutorial.

    I’m looking forward to the next one in the series.

  • Sam

    This series is getting better. Added your blog yo my bookmark.

  • http://codeigniter.com/ Matt G

    Yay!! Thanks for the post… can’t wait for the next one!

  • http://www.imediasolutions.org randomideas

    Good Job guys! Can’t wait for the next posts.

  • http://hammudi.com Muhammad Babsail

    nice templates, very clean..
    waiting for the next part…

  • http://www.ruancarlos.com.br Ruan

    waiting for the next part…²

  • red

    So I can add this to Joomla’s list of e carts?

    Just kidding.
    Nice tutorial, hope you make part 4 soon…

  • http://www.panagamers.com demogar

    I think you must take a look at the CodeIgniter version that is at the SVN repository.
    It has a new library called “Cart” and it will make this kind of things a lot easier.

  • http://www.blog.dileepsharma.com Dileep K Sharma

    Hello Insic,
    Is this demo link actualy working? It says me “The web page is not available.” Please confirm. I am excited to see this live.

  • http://blog.insicdesigns.com insic2.0

    @Dileep K Sharma Yes, the demo link is working.

  • lagoona2099

    good tutorial. when is part 4 coming out? looking forward to it!

  • http://www.marocplus.net Directory marocplus

    very good Application

  • http://anime7graphic.blogspot.com anime7graphic

    Waw, I love this article because I need it for my online shop web…
    Thank’s Insinc design…. It is good job

    Regard

  • http://linuxinicio.blogspot.com Copo de Nieve

    This tutorial is great!
    I really want to read the rest of it!

    Keep the great job!!

  • http://eyoosuf.blogspot.com Yoosuf

    so far well, but the functional sections to come very soon yarrrr, because still it didn’t complete the topic!!

    so please!

  • Pingback: Building a basic PHP E-Commerce Application using CodeIgniter Framework - Part 3 | INSIC 2.0 Web Development & Design Blog

  • http://edwardawebb.com Eddie

    I am impressed with the design images you provide for each article.  How much time does that take? I have no graphic design talent :(

  • Frankie

    Hi :-)
    Very good tutorial. I’m working with your tut. to get a connection on this (http://www.thewojogroup.com/2008/10/simplecartjs-paypal-e-commerce-in-minutes/) shopping cart into codeigniter.

    Keep up the very good work. Two thumbs up ! :-)

  • kazuya

    hi,

    great tutorial!  especially for beginners like me.

    is there any site that have a step by step tutorial regarding CRUD and
    user management?

    thanks… waiting for part 4

  • Hermes Alves

    Congratulations for the post! When going out to party 4?

  • marc

    Hello, It’s nice to know you have a place to share one of my fav. framework. I just found your blog and also excited to see the next part.

  • http://www.findonlineschools.com Find Online Schools

    Thank you for this tutorial.  I am looking forward to the next part in the series.  We use codeigniter to develop all of our web applications and have really loved the flexibility.

  • Felix Karlsson

    Thank’s a lot for this tutorial, just what I needed.
    I’m definitely looking forward to the next part!

  • Felix Karlsson

    Hmm.. Just one problem. There is no public/css folder, so where should i create it? I’ve tried some different locations, but none of them have given a succesful result! Please help :)

  • Felix Karlsson

    Oh, sorry.. The first sentence of this tutorial solved it, lol.

  • Zaw

    Wee! this looks as beautiful as u r XD

  • http://trimo.i-cornershop.com fleacool

    thanks for u’r tutorial
    I’ll try and implement this online store ^^

  • http://www.atdesigncm.com Thaninrat Thanatharavat

    thank for tutorial. Can’t wait for next one :-)

  • http://wowcruit.com Chris

    Aww its not out yet. Darn. But its a great tutorial

  • http://i-zero.net Taqim

    I like ur tutorial.. thank a lot !!! ^_^

  • http://pahtanahi Imran

    waiting for next part

  • Misheck

    Geat Tutorial but whats happened to part 4? Does any one have part 4?

  • Dien Nguyen

    Good tutorial. Thank.

  • Vishnu

    Thankx for the post, when will you post the next tutorial?

  • http://www.haciendasenyucatan.com Frankvazk

    That´s a great tutorial i can´t wait for the rest of this useful tut. Thanks

  • PIT

    hey! we need the part 4 please!!
    i can’t stand end this great tutorial!!! so close the end of the excellent codeigniter resource

    btw can someone upload or give a working link to the zip file the “download” link is dead :(

    thanx for your work, it could be my codeigniter bible :D

  • http://www.kazembe.sofnetzm.com Kazembe

    great tut thanx, the download link isnt working, may somebody pls post a working link? can wait to see it.

  • PIT

    i searched the whole web for hours but didn’t find nor the archives nor the part 4…i’m so sad :(
    what i can give you are just some dummies image i quickly generated for it. Place them in /images/ dir.
    just “images/body-bg.gif” (first css line) is missing
    anyway here’s the link to these files:
    http://www.filesavr.com/CXqiDrz2

    but we would appreciate someone having the real files to upload them! thanx

  • firexas

    very very goooooooooooooooooooooooooooooooodd….

    I’m wait next tutorial..

    thanks..

  • Ciprian
  • Masud

    Really very nice tutorials. It’s very help full for us plz I want to see your next part i mean part 4.

    @@@ The demo and download link not working

  • Fabio

    Great tutorial thanks,

    “@@@ The demo and download link not working”

  • Dmitriy
  • Pingback: Développer une boutique en ligne avec le framework MVC Codeigniter « Trois Point Zéro – webdesign, développement et actualité autour du web par Grégory BABONAUX, concepteur web freelance

  • Mahesh

    Very useful tutorial. Thanks a lot for the post.
    The Demo and Download links are not working.
    Does anyone have them?

  • jacinto

    Por favor la parte 4, gracias por compartir
    (please the 4 part, thanks for sharing) :)

  • corneleon
  • Angry bird

    Not complete tutorial… why are you posting incomplete tutorial… its totally nerd

  • Humayun

    Please complete your tut!! thanxs

  • Carlos

    Why, OH GOD WHY! Such a good tutorial isn’t complete… No part 4 in 3 years?

    Anymay, thanks for the really nice work, I’m starting from here my learning journey for CodeIgniter.

    • http://keenanpayne.com Keenan Payne

      I was thinking the same thing. I really wish this tutorial would have been completed.

  • http://www.websolutionsmantra.com ronnie

    Incomplete tutorial! not good;))

  • nithin

    hello the download links and demo links not working

  • http://www.roobon.net/ Syed Ziaul Habib

    Yes, would like to see part 4