Wednesday, May 13, 2009

how to create a site with joomla

How to Create Sections:-

Login to admin and go to section manager. The Section Manager (Content > Section Manager), we see that it is blank. This is because we installed our site with no content in the installation process.

Here we created a section About us
After we have set up the section we now have

- About us
- Services
- Testimonials
- FAQ

How to Create Category:-


We go to the Category Manager (Content > Category Manager) and set up the categories we need. Notice we have to make sure we put it in the correct section (Services in this case) and save it as before.

Then following categories created are:-
- What we are
- What we offer
- Benefits
- Projects
- History
- Leadership and team
- Why India?
- Contact us
- Faq

How to Create Articles:-


Let's go to the Article Manager (Content > Article Manager) and open the About us content article

You will see here the title is About us which is the page title, the section selected is About us and the category What we are. Also note that to display the content of this page we FrontPage so that it should be shown on the front page.

Similarly create all the required article content for each respective category to their respective sections.

Now that we have all the content ready the question is how to assemble it and link it .
So now we start with Creating Menu and Menu Items.

As per are Web Needs We need Main Menu, Top Menu and Footer Menu and we create this in the Menu Manger as shown below,

How we create Main Menu:-


First let's go to the main menu (Menu Manager > main menu) and create a link to About Us. Here we get first option to select the article content from the Menu Items page, so now for about us we need to select the Articles and under this we have article Article Layout and select that , then we have a page.

In the figure you will see that Article layout is selected for Main Menu Type you can change that as per you layout needs, you will also see options to add menu item title and on the right you option to select the article we just created here we select company article content to our needs. You will also see the option to select where to display in the drop down here we selected Main Menu and the parent item as the TOP if it has any sub items we can do that by creating a new Menu Item and selecting the about us we already see a example Our Services.

Similarly we create Top Menu and Footer menu items.
Note that for each Menu type in the Module manager a module is created and see how they are related. In this case for Main Menu a Module Main Menu is created in the module manger. So you understand how a module is related to Menu Type .

We can also extend Joomla. There are extensions available, you can use this http://extensions.joomla.org/ to download various extensions, Plug-ins, Modules and also themes

I have use Testimonials extension in my site I will show how to add to Joomla
Downloaded the Extension from http://www.rswebsols.com/downloads/category/14-download-rsmonials-all

Installing Extensions


All extensions will come in the form of compressed zip files and are installed via the same process. To install, you simply use the Extension Manager. Go to Extensions>Install/Uninstall. This will show the Extension Manager,

If it’s a successful installation it will say so .It it is you will see a link Rsmonial where it allows you to add any testimonials from admin.
Earlier for the front end we created a section Testimonial for this section we will add this extension as we need the testimonials to be displayed on each and every page we create a Menu Type Testimonial Select the Rsmonial the menu item type and for that respective Menu Typea module will be created in the Module Manger Enable it.

So you see the Testimonial in the Menu Type here you also get option to add testimonials from the front end and done.

Finally we our complete website up and Running.

Friday, April 17, 2009

Creating site with Joomla

Creating GWT SITE with Joomla



Joomla is Content Management System (CMS) .With Joomla you for sure can build a really powerful site. So what does CMS means? To tell you in a simple it’s a system that controls each and every element of your site right from pictures to file , from alignment to placement , from header to footer , so it’s a software that helps to build a site even if you do not have any coding knowledge simply clicks will do .
Let’s start with Installation of Joomla:-
Download it from: - http://www.joomla.org/download.html
Joomla installation is very easy just extract the contents of file to new root folder let say Joomla and extract in this folder once done go to the url let say http://localhost/joomla/ and follow the simple instruction on each page and make sure you do as they say, click next and next until it takes you to the final page where you get options to click on either your sites main page or the admin page and done.

Now how to customize the Joomla according to our needs with our designs so let’s begin

you always starts with analyzing how the structure of my site should be what should it display in the header , main menu , front page , footer and any additional functionality so here advantage is Joomla gives you the option for dividing the thing so that you gets chance to work on each one at a time . Begin with our structure and it would be:
The sections are:-
1) About us.
2) Testimonial.
3) Contact us.
4) FAQ.
So here each section does have some task to do here,
Under about us sections we have tasks divided by categories,

The categories are:-
1) What we are
2) What we offer
3) Benefits
4) Projects
5) History
6) Leadership and team
7) Why India?
8) Contact us
9) Faq

So what each categories do:
Now the categories listed have articles which actually help to build the page for its respective category so here articles which finally holds the content for each of its category.
So here the articles for each category are:
1) What we are (Category) –

About us page (Article) –

- This page tells about the company

2) What we offer (Category) –

Services page (Article) –

- This tells about all services as a company we offer to our clients right from technology to project dispatch

3) Benefits (Category) –

Benefits page (Article) –

- Benefits page this tells about the benefits the clients get from our services


4) Projects (Category) –

Projects page (Article) –

- Projects page list all the projects done by our company

5) History (Category) –

History page (Article) –

- History page tells about the company when it got started how what motive and how we grow

6) Leadership and Team (Category) –

Leadership and Team page (Article) –

- This page tells about the leaders in Our company leading the way to success

7) Why India? (Category) –

Why India? (Article) –
- This page tells about why choose India for the outsourcing.

8) Contact Us (Category) –

Contact us page (Article) –
- This page has the contact details about our company

9) FAQ (Category) –

FAQ page (Article) –
- This page has the question answered for all those frequently asked questions.

So this is how the structure is organized.

We already know that in CMS we have everything in the front end is controlled by admin so let’s understand how to create Sections, Category and Articles

Monday, March 30, 2009

Progress bar using PHP

Upload progress bar



An extension to track progress of a file uploads. It is only known to work on Apache and at least PHP 5.2 is needed.

To Install

In windows it’s quite easy just copy and paste the uploadprogress.dll extension and enables the extension in the php configuration file and that’s it.

However in linux or unix, installation is different you need to either install it from the site http://pecl.php.net/package/uploadprogress via a pear or pecl in the server or download the stable release from the site and then install.

What to configure in php.ini

[uploadprogress]

extension=uploadprogress.dll

uploadprogress.file.contents_template = "c:\temp\upl_%s.txt" uploadprogress.file.filename_template = "c:\temp\upl_%s.txt"

uploadprogress.file.upload_identifier="UPLOAD_IDENTIFIER"

uploadprogress.update_interval=500

uploadprogress.delete_finished=1

(please set the path as per linux where it says c:\temp\upl_%s.txt)

after adding this lines in php.ini create a folder temp in a location set in the above php.ini

That’s all … and start running the progressbar

The progress bar is tested in firefox and IE and is working fine.

Friday, March 20, 2009

Integrating Paypal Shopping cart

The PayPal Shopping Cart – Add to Cart

With the PayPal Shopping Cart, you can let buyers select multiple items on your website and Pay for them with a single payment. Buyers click Add to Cart buttons to add items to their Virtual PayPal Shopping Carts, and they click View Cart buttons to review the items in their Carts before they check out and make their payments.

Sample HTML Code for a Basic Add to Cart Button. The sample HTML code below illustrates a basic Add to Cart button with these features:
An item named “QA Testing”.
An item price of $990.95 USD.
􀁺 PayPal calculates tax and shipping based on rates that you set up in your PayPal account.
􀁺 The buyer’s PayPal Shopping Cart opens in a separate browser window or tab.

form target=paypal action=https://www.paypal.com/cgi-bin/webscr method=post

Identify your business so that you can collect the payments.
input type=hidden name=business value=abc@abc.com

Specify a PayPal Shopping Cart Add to Cart button.
input type=hidden name=cmd value=_cart
input type=hidden name=add value=1

Specify details about the item that buyers will purchase.
input type=hidden name=item_name Value=QA and Software Testing
input type=hidden name=amount value=990.95
input type=hidden name=currency_code value=USD

Continue shopping on the current webpage of the merchant site.
The below value is replaced when buyers click Add to Cart
input type=hidden name=shopping_url value=http://www.globalworldtech.com/services.html
input type=hidden name=shipping value=4
input type=hidden name=handling_cart value=24

Display the payment button.
input type=image name=submit border=0 src=https://www.paypal.com/en_US/i/btn/btn_cart_LG.gif
alt=PayPal - The safer, easier way to pay online
img alt="" border=0 width="1" height="1" src=https://www.paypal.com/en_US/i/scr/pixel.gif

form

Variables required to tell PayPal the type of form it is are:

1) cmd
The cmd variable is always required in a FORM. Its value determines which Website Payments Standard checkout experience you are using to obtain payment.

Allowed Values for cmd Variable
Value of cmd Description
a) _xclick The button that the person clicked was a Buy Now button
b) _donations The button that the person clicked was a Donate button
c) _xclick- subscriptions the button that the person clicked was a Subscribe button.
d) _cart For shopping cart purchases; these additional variables specify the Kind of shopping cart button or command:
􀁺 add – Add to Cart buttons this must be set to 1
􀁺 display – View Cart buttons other alternative to add
􀁺 upload – The Cart Upload command tells it’s a third party cart must be set to1.

2) shopping_url
Use the shopping_url variable to let PayPal control which page buyers return to when they click the Continue Shopping button.

3) handling_cart

Single handling fee to be charged cart-wide. If handling_cart is used in multiple Add to Cart buttons, the handling_cart value of the first item is used.

4) amount
Required Price of the item or the total price of all items in the shopping
Cart.

5) business
Required Your PayPal ID or an email address associated with your PayPal
account. Email addresses must be confirmed

6) item_name
Required Name of the item or a name for the entire Shopping Cart

7) currency_code
The currency of the payment. The default is USD.

8) shipping
The cost of shipping the item. This use of the shipping variable is valid only for Buy Now and Add to Cart buttons.

There are few other additional html variables like tax, tax_rate ,undefined_quantity,weight,weight_unit also can defined if required you can check the url
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_Appx_websitestandard_htmlvariables for all html variables.

Sunday, March 1, 2009

Abstract Class
An abstract class is a class with or without data members that provides some functionality and leaves the remaining functionality for its child class to implement. The child class must provide the functionality not provided by the abstract class or else the child class also becomes abstract.
Objects of an abstract and interface class cannot be created i.e. only objects of concrete class can be created.
To define a class as Abstract, the keyword abstract is to be used e.g. abstract class ClassName { }
Eg :
abstract class Furniture {
private $height, width, length;

public function setData($h, $w, $l) {
$this->height = $h;
$this->width = $w;
$this->length = $l;
}

//this function is declared as abstract and hence the function
//body will have to be provided in the child class
public abstract function getPrice();

}


class BookShelf extends Furniture {

private $price;

public setData($h, $w, $l, $p) {
parent::setData($h, $w, $l);
$this->price = $p;
}


//this is the function body of the parent abstract method
public function getPrice() {
return $this->price;
}
}
In the above example, the method getPrice() in class Furniture has been declared as Abstract. This means that its the responsibility of the child class to provide the functionality of getPrice(). The BookShelf class is a child of the Furniture class and hence provides the function body for getPrice().
Private methods cannot be abstract
If a method is defined as abstract then it cannot be declared as private (it can only be public or protected). This is because a private method cannot be inherited.

Interface Class
Interface is a class with no data members and contains only member functions and they lack its implementation. Any class that inherits from an interface must implement the missing member function body.
Interfaces is also an abstract class because abstract class always require an implementation.
In PHP 5, interfaces may declare only methods. An interface cannot declare any variables. To extend from an Interface, keyword implements is used. PHP5 supports class extending more than one interface.
Eg:
interface employee
{
function setdata($empname,$empage);
function outputData();
}

class Payment implements employee
{
function setdata($empname,$empage)
{
//Functionality
}

function outputData()
{
echo "Inside Payment Class";
}
}

$a = new Payment();
$a->outputData();

Wednesday, February 18, 2009

Polymorphism

Polymorphism is derived from two Greek words. Poly (meaning many) and morph (meaning forms). Polymorphism means many forms. In C you have two methods with the same name that have different function signatures and hence by passing the correct function signature you can invoke the correct method.
The meaning with Object Oriented languages changes. With Object Oriented language polymorphism happens:
When the decision to invoke a function call is made by inspecting the object at runtime it is called Polymorphism
Method polymorphism cannot be achieved in PHP :
The reason why polymorphism for methods is not possible in PHP is because you can have a method that accepts two parameters and call it by passing three parameters. This is because PHP is not strict and contains methods like func_num_args() and func_get_arg() to find the number of arguments passed and get a particular parameter.
Because PHP is not type strict and allows variable arguments, this is why method polymorphism is not possible.
PHP 5 Polymorphism
Since PHP 5 introduces the concept of Type Hinting, polymorphism is possible with class methods. The basis of polymorphism is Inheritance and overridden methods.
Eg:

class BaseClass {
public function myMethod() {
echo "BaseClass method called";
}
}

class DerivedClass extends BaseClass {
public function myMethod() {
echo "DerivedClass method called";
}
}

function processClass(BaseClass $c) {
$c->myMethod();
}

$c = new DerivedClass();
processClass($c);

In the above example, object $c of class DerievedClass is executed and passed to the processClass() method. The parameter accepted in processClass() is that of BassClass. Within the processClass() the method myMethod() is being called. As per the definition “When the decision to invoke a function call is made by inspecting the object at runtime it is called Polymorphism”, myMethod() will be called on object DerievedClass. The reason why this happens is because the object of DerievedClass is being passed and hence the method myMethod() of DerievedClass will be called.

Final Class and Methods
Final Class :

A final class is a class that cannot be extended. To declare a class as final, you need to prefix the ‘class’ keyword with ‘final’.
Eg:
final class BaseClass {
public function myMethod() {
echo "BaseClass method called";
}
}

//this will cause Compile error
class DerivedClass extends BaseClass {
public function myMethod() {
echo "DerivedClass method called";
}
}

$c = new DerivedClass();
$c->myMethod();

In the above example, BaseClass is declared as final and hence cannot be extended (inherited). DerivedClass tries to extend from BaseClass and hence the compiler will throw a compile error.
Final Method :
A final method is a method that cannot be overridden. To declare a method as final, you need to prefix the function name with the ‘final’ keyword.
Eg:
class BaseClass {
final public function myMethod() {
echo "BaseClass method called";
}
}

class DerivedClass extends BaseClass {
//this will cause Compile error
public function myMethod() {
echo "DerivedClass method called";
}
}

$c = new DerivedClass();
$c->myMethod();
In the above example, DerivedClass extends from BaseClass. BaseClass has the method myMethod() declared as final and this cannot be overridden. In this case the compiler causes a compile error.

Static Data Member :
A data member that is commonly available to all objects of a class is called a static member. static members share the memory space between all objects of the same class.

Defining static data members in PHP5
To define a static member in PHP5 you need to prefix the class member name with the keyword ’static’.
Eg:
class Customer {

private $first_name; // regular member
static public $instance_count; //static data member

}
Accessing static data members in PHP5
A static member data can be accessed using the name of the class along with the scope resolution operator (::) i.e. you don’t need to create an instance of that class
Eg:
class Customer {

static public $instance_count = 0; //static data member

public function __construct() {
Customer::$instance_count++;
}

public function __destruct() {
Customer::$instance_count--;
}

public function getFirstName() {
//body of method
}

static public function getInstanceCount() {
//body of method
}
}

$c1 = new Customer();
$c2 = new Customer();

echo Customer::$instance_count;

Output:
2
In the above example, $instance_count is a static data member. Every time a new object is created the constructor is executed and the $instance_count variable is incremented by one. To echo the value contained in $instance_count variable, we use the :: (scope resolution) operator.

Static Method :
A static method is a class method that can be called without creating an instance of a class. Such methods are useful when creating utility classes.
Defining static methods in PHP5
To define a static data methods in PHP5 you need to prefix the class method name with the keyword ’static’.
Eg:
class Customer {

public function getFirstName() {
//body of method
}

static public function getInstanceCount() {
//body of method
}
}
Accessing static method in PHP5
A static method can be accessed using the name of the class along with the scope resolution operator (::) i.e. you don’t need to create an instance of that class. However, you can also access it with an instance variable.
Eg:

class Customer {

static public $instance_count = 0; //static data member

public function __construct() {
Customer::$instance_count++;
}

public function __destruct() {
Customer::$instance_count--;
}

public function getFirstName() {
//body of method
}

static public function getInstanceCount() {
return Customer::$instance_count;
}
}

$c1 = new Customer();
$c2 = new Customer();

echo Customer::getInstanceCount(); //this is using the scope resolution operator
echo $c1->getInstanceCount(); //this is using the instance variable
Output:
2
2
Rules to keep in mind for static methods

  • A static method can only access static data members

  • A static method does not have access to the $this variable

Thursday, February 12, 2009

Access specifiers:
Access specifiers are used to identify access rights for the data and member functions of the class. Access specifiers specify the level of access that the outside world (i.e. other class objects, external functions and global level code) have on the class methods and class data members. There are three main types of access specifiers in PHP.

  • private

  • public

  • protected


1) Private
A private access specifier is used to hide the data member or member function to the outside world. This means that only the class that defines such data member and member functions have access them.
Eg:

class Customer {
private $name;

public function setName($name) {
$this->name = $name;
}

public function getName() {
return $this->name;
}
}

$c = new Customer();
$c->setName("Sunil Bhatia");
echo $c->name; //error, $name cannot be accessed from outside the class
//$name can only be accessed from within the class

echo $c->getName(); //this works, as the methods of the class have access
//to the private data members or methods

In the above example, echo $c->name will give you an error as $name in class Customer has been declared private and hence only be accessed by its member functions internally.

2) Public
A public access specifier provides the least protection to the internal data members and member functions. A public access specifier allows the outside world to access/modify the data members directly unlike the private access specifier.
Eg:
class Customer {
public $name;

public function setName($name) {
$this->name = $name;
}

public function getName() {
return $this->name;
}
}

$c = new Customer();
$c->setName("Sunil Bhatia");
echo $c->name; // this will work as it is public.
$c->name = "New Name" ; // this does not give an error.

In the above example, echo $c->name will work as it has been declared as public and hence can be accessed by class member functions and the rest of the script.
3) Protected :
A protected access specifier is mainly used with inheritance. A data member or member function declared as protected will be accessed by its class and its base class but not from the outside world (i.e. rest of the script). We can also say that a protected data member is public for the class that declares it and it’s child class; but is private for the rest of the program (outside world).
Eg:
class Customer {
protected $name;

public function setName($name) {
$this->name = $name;
}

public function getName() {
return $this->name;
}
}

class DiscountCustomer extends Customer {

private $discount;

public function setData($name, $discount) {
$this->name = $name; //this is storing $name to the Customer
//class $name variable. This works
// as it is a protected variable

$this->discount = $discount;
}
}

$dc = new DiscountCustomer();
$dc->setData("Sunil Bhatia",10);
echo $dc->name; // this does not work as $name is protected and hence
// only available in Customer and DiscountCustomer class

In the above example, echo $dc->name will not work work $name has been defined as a protected variable and hence it is only available in Customer and DiscountCustomer class.
Important Note of Access Specifier in PHP5
In PHP5, access specifiers are public by default. This means that if you don’t specify an access specifier for a data member or method then the default ‘public’ is applicable.