- Stream oriented api: Simple api for xml or SAX, it is event based.
- Tree traversal api: Dom is a tree-traversal api. DOM implementation is memory intensive, as it loads the whole xml tree before accessing data.
- Xml data binding: which is a automated way to convert XML document.
- Declarative transformation languages: XSLT, XQuery.
Tuesday, September 29, 2009
Api for XML
There are various api for accessing xml documents. They are the following-
Monday, September 28, 2009
Introduction to JSON
JSON means javascript object notation. JSON is lightweight and very easy to parse.
It is not a markup language. The basis of JSON is that javascript’s object literal
is the ideal way for transmitting object oriented data across the network. Json made it easier to produce distributed object and applications. JSON does not support octal or hex characters. The character encoding of json is always Unicode. Json is the preferred way for ajax applications. A response text can be converted to javascript with eval() function. json's values can be used directly, no convertiion needed. this is the most significant reason to use json. json has no namespaces so there is no nesting and it uses context. JSON doesn't have any validator.
It is not a markup language. The basis of JSON is that javascript’s object literal
is the ideal way for transmitting object oriented data across the network. Json made it easier to produce distributed object and applications. JSON does not support octal or hex characters. The character encoding of json is always Unicode. Json is the preferred way for ajax applications. A response text can be converted to javascript with eval() function. json's values can be used directly, no convertiion needed. this is the most significant reason to use json. json has no namespaces so there is no nesting and it uses context. JSON doesn't have any validator.
Sunday, September 27, 2009
Why should I use static variable?
Let’s see the difference between static and non-static variable:
Static is used for those method and variables which are accessed from other classes or functions also. If we use non-static, then we need to instantiate the class each time to use that methods or variables. Static variable has it’s scope until the script ends, whereas a non-static variable lost it’s value when it’s scope ends.
Static is used for those method and variables which are accessed from other classes or functions also. If we use non-static, then we need to instantiate the class each time to use that methods or variables. Static variable has it’s scope until the script ends, whereas a non-static variable lost it’s value when it’s scope ends.
Wednesday, September 23, 2009
OOP vs procedural
OOP provides ways for extensible application. this approach removes the drawbacks of procedural paradigm. it gives first priority to data. it packs data and functions, which have access to this functions. this avoids unauthorized access to functions. So, OOP gives us ability of reuse, inheritence, access modifier.
procedural provides ways for fast, shortcut approach for programming. so, before coding we must think what we want to do. if we want a small coding to do a small job, then we must go for procedural approach. But as the requirements grew, it was seen that the programs were getting larger and larger and it became difficult to debug. So functions were introduced to reduce the size of the programs and improve readability in them. Still that was not enough. In this approach, data is getting corrupted, as many functions which are not allowed to access the function can access the functions. so, here more focus was given on functions, rather than data.
procedural provides ways for fast, shortcut approach for programming. so, before coding we must think what we want to do. if we want a small coding to do a small job, then we must go for procedural approach. But as the requirements grew, it was seen that the programs were getting larger and larger and it became difficult to debug. So functions were introduced to reduce the size of the programs and improve readability in them. Still that was not enough. In this approach, data is getting corrupted, as many functions which are not allowed to access the function can access the functions. so, here more focus was given on functions, rather than data.
Sunday, September 20, 2009
Problem with normal and session variable having same name
If your register_globals is set to ON, then a normal variable will overwrite a session variable with the same name. In webid, I faced this problem. It's not a good practice to turn ON register_globals. So, turn it Off it will fix the problem with same variable name.
Thursday, September 17, 2009
xml vs database
XML can be used as databases. But the question is that why should I use it or why should I avoid it? XML has the properties of storage, portability, schemas. Xml is self describing means the elements, attributes tells what the data it contains. It also describes data in tree or graph structure.
Xml provides many qualities of databases.
1. Storage: Xml documents.
2. Schemas: DTDs, Xml schemas.
3. Query languages: Xpath, Xquery.
4. Programming interfaces: SAX, DOM.
And it also lacks some of the cool features of databases.
1. Security.
2. Integrity.
3. Indexes.
4. Transaction.
5. Efficient storage.
6. Multi user access.
7. Triggers.
8. Queries across multiple documents.
So, xml can be used as a database for few users, small amount of data. But for product environment where there will larger data, huge user, need data integrity, there needs databases. So, there is very little advantage to use xml as a database.
Xml provides many qualities of databases.
1. Storage: Xml documents.
2. Schemas: DTDs, Xml schemas.
3. Query languages: Xpath, Xquery.
4. Programming interfaces: SAX, DOM.
And it also lacks some of the cool features of databases.
1. Security.
2. Integrity.
3. Indexes.
4. Transaction.
5. Efficient storage.
6. Multi user access.
7. Triggers.
8. Queries across multiple documents.
So, xml can be used as a database for few users, small amount of data. But for product environment where there will larger data, huge user, need data integrity, there needs databases. So, there is very little advantage to use xml as a database.
Wednesday, September 16, 2009
.htaccess intro
.htaccess files are used to modify server configuration on per-directory basis. It is used when a user doesn’t has access to modify server configuration settings. The directives in .htaccess file is applied for the current directory and subdirectories. .htaccess uses those directives that has their AllowOverride property set to not none.
If we can, we should avoid using .htaccess file mainly for the following 2 reasons –
1. When we set AllowOverride property to allow modification in .htaccess files, then the server checks every directory for .htaccess file. This hit the performance.
2. Second one is security. We are allowing users to change server configuration. So, it may become a security hole.
If we can, we should avoid using .htaccess file mainly for the following 2 reasons –
1. When we set AllowOverride property to allow modification in .htaccess files, then the server checks every directory for .htaccess file. This hit the performance.
2. Second one is security. We are allowing users to change server configuration. So, it may become a security hole.
Tuesday, September 15, 2009
Use component as multipart document
This will use different component of a webpage as an attachment. So, components will be loaded with one http request. This will improve webpage loading time. But iphone doesn’t support this technique.
minify js and css
We can minify javascript and css, so the loading of these files will be faster. There are two popular tools: jsmin and YUI compression. YUI compression can compress CSS files also. Minify will reduce size upto 25% of it size. We can use minify after gzip, it will reduce the size upto 5%. Minify removes redundant contents.
Reduce DNS lookups
Each DNS will be converted to IP address. Server will wait until the conversion completes. DNS lookup takes 20-100 miliseconds. The DNS is cached for later use. Firefox uses 1 min, IE uses 30 min for the dns caching. This caching is done on a special caching server. Each browser has a own DNS cache. It also stores the information on the operating systems cache.
Reducing DNS lookup cuts response time, but also reduces parallel downloading so increases response time. We can use upto 4 hostnames which will increase our speed.
Reducing DNS lookup cuts response time, but also reduces parallel downloading so increases response time. We can use upto 4 hostnames which will increase our speed.
Use external files for javascript and css
Using external files for javascript and css will reduce the file size without increasing the number of http requests. But we can use inline code for home page which has less page views. So, we can use caching for those pages which reuses same scripts and stylesheets.
There are some files which are common on homepage and other pages. For that case, we can load inline codes for homepage and then we can load those scripts by external files.
There are some files which are common on homepage and other pages. For that case, we can load inline codes for homepage and then we can load those scripts by external files.
CSS expressions
CSS expressions use javascripts. And the page is evaluated for scrolling or even mouse moving. We avoid expressions as they create many evaluation to the page. So, if we need to use expressions we must use one-time loading.
Put scripts at the bottom
According to the http/1.1 a page can download no more than 2 scripts at a time. While a script is downloading, however, the browser won't start any other downloads, even on different hostnames.
Sometime, we can’t put scripts at the bottom. When the scripts load some content that will be used in the middle of the page, then we need to call the script early. We can use DEFER attribute which shows the script does not contain document.write. but firefox doesn’t support this attribute.
Sometime, we can’t put scripts at the bottom. When the scripts load some content that will be used in the middle of the page, then we need to call the script early. We can use DEFER attribute which shows the script does not contain document.write. but firefox doesn’t support this attribute.
Loading stylesheets on top
Always include stylesheets in the head tag. This will load the page faster. Users want to see their pages faster. So, for this purposes, the loading image is getting popular. So, if we set the stylesheets in the head tag, then the images, banner, header will load faster and will give the user an impression of page loading. If we place the stylesheet at the bottom, then it may show a blank page for some time in some browser like internet explorer.
Gzip contents
Web content size can be reduced by gziping them. If we set accept-encoding to gzip or any other compression techniques, then the web server responses with the content-encoding header that tells the browser to compress the web content.
We can’t compress images and pdf files as they are already compressed. By compressing these may increase web content size.
We can’t compress images and pdf files as they are already compressed. By compressing these may increase web content size.
Cache control
For caching features, we can use two techniques-
1. For static contents, we can set the expire attribute to a furthest future.
2. For dynamic contents, we can set an appropriate cache-control.
For static contents, like images, stylesheet, flash etc, can be cached in the browser for faster page load. This will reduce http request time. This will not effect for the first time the page loads, but the result will be at later page requests when the cache will be full.
1. For static contents, we can set the expire attribute to a furthest future.
2. For dynamic contents, we can set an appropriate cache-control.
For static contents, like images, stylesheet, flash etc, can be cached in the browser for faster page load. This will reduce http request time. This will not effect for the first time the page loads, but the result will be at later page requests when the cache will be full.
Using content delivery network
Content delivery network(CDN) is a distributed service of static contents i.e. images, stylesheets, javascripts, flash etc. it will reduce http loading time drastically. There are many organization who provides this service. CDN uses many distributed servers who will store the static contents. In this case, the nearest or the shortest response time server is chosen.
Reducing HTTP request
To speed up a web page loading, our first goal will be to reduce the number of http request. The less the http request, the faster the page will be load. There are many ways to reduce http request. We can use css sprites, combined css, image maps etc. there is another technique called inline images, it uses of the form, data: mediatype;base64;data.Another way to reduce the number of http request is by having a full cache.
Minify your javascript file with jsmin
It will minify the javascript file. We minify javascript files so it will reduce page loading. JSMin first replaces carriage returns ('\r') with linefeeds ('\n'). It replaces all other control characters (including tab) with spaces. It replaces comments in the // form with linefeeds. It replaces comments in the /* */ form with spaces. There are many supported programming language available to use jsmin. I used php.
Wednesday, September 2, 2009
Affiliate program in prestashop
Prestashop 1.2 comes with a affiliate module. By this we can track affiliates. You need to set every thing manually here.
To start with affiliate program, go to the back office > stats > referrers. To add a new affiliates, click the add new button.
You need to create an affiliate account first with username and password. Under that section there is the url by which you can see the affiliate space on the front office.
With the HTTP_REFERER section, set the domain name in the include field that you want to track as your affiliate domain. We can use the keyword like ‘MySQL LIKE’ feature, for example, put ‘%google%’, this will track all the request that come from the google search engine.
With the Request_uri section, we can set the last part of the query string. Our affiliate program will track this url. For example, someone uses %aff% in the include field. So, his affiliate link will be any url of the shop that have ‘aff’ in it’s url.
Then save your changes. You can see your affiliate statistics in the front panel. It will take approximately an hour to see the changes.
See the book OpenCart 1.4 Template Design Cookbook. See the book Joomla Mobile Development Beginners Guide
To start with affiliate program, go to the back office > stats > referrers. To add a new affiliates, click the add new button.
You need to create an affiliate account first with username and password. Under that section there is the url by which you can see the affiliate space on the front office.
With the HTTP_REFERER section, set the domain name in the include field that you want to track as your affiliate domain. We can use the keyword like ‘MySQL LIKE’ feature, for example, put ‘%google%’, this will track all the request that come from the google search engine.
With the Request_uri section, we can set the last part of the query string. Our affiliate program will track this url. For example, someone uses %aff% in the include field. So, his affiliate link will be any url of the shop that have ‘aff’ in it’s url.
Then save your changes. You can see your affiliate statistics in the front panel. It will take approximately an hour to see the changes.
See the book OpenCart 1.4 Template Design Cookbook. See the book Joomla Mobile Development Beginners Guide
Labels:
affiliate program,
prestashop
Tuesday, September 1, 2009
how to create hooks in prestashop
Creating hook is pretty easy in prestashop, add a new row with the ps_hook table in the databases. Enter the name of the hook and the id of the hook. Now, go to the php file in which you want to add the hook. Add ‘HOOK_demo’ => Module::hookExec(‘demo’) into the smarty assign variable where demo is the hook name. Then place the { HOOK_demo } in the .tpl file where you want to see the content.
how to write a module with prestashop
Every module is load with a hook. A hook is a module holder. Prestashop has some default hooks. We will see later how to createhooks.
Ok, now lets start to make a module with prestashop. First make a folder with the modulename. Create a .tpl file with the modulename. Write the presentation code here.
Then create a .php file with the modulename. The following is a dummy class for our module.
// class name must be same with the modulename, not case sensitive.
class Fashion extends Module
{
function __construct()
{
$this->name = 'fashion'; // this is the name of the module
$this->tab = 'Blocks';
$this->version = 1.0;
parent::__construct(); // The parent construct is required for translations
$this->page = basename(__FILE__, '.php');
$this->displayName = $this->l('Block Fashion');
$this->description = $this->l('Add a fashion block');
}
function install()
{
if (!parent::install())
return false;
if (!$this->registerHook('leftColumn')) // we are setting this module with the left column.
return false;
return true;
}
/**
* Returns module content
*
* @param array $params Parameters
* @return string Content
*/
// as we are setting this module on left column, we are using this hook to load our module.
function hookLeftColumn($params)
{
return $this->display(__FILE__, 'fashion.tpl');
}
}
?>
Ok, now lets start to make a module with prestashop. First make a folder with the modulename. Create a .tpl file with the modulename. Write the presentation code here.
Then create a .php file with the modulename. The following is a dummy class for our module.
// class name must be same with the modulename, not case sensitive.
class Fashion extends Module
{
function __construct()
{
$this->name = 'fashion'; // this is the name of the module
$this->tab = 'Blocks';
$this->version = 1.0;
parent::__construct(); // The parent construct is required for translations
$this->page = basename(__FILE__, '.php');
$this->displayName = $this->l('Block Fashion');
$this->description = $this->l('Add a fashion block');
}
function install()
{
if (!parent::install())
return false;
if (!$this->registerHook('leftColumn')) // we are setting this module with the left column.
return false;
return true;
}
/**
* Returns module content
*
* @param array $params Parameters
* @return string Content
*/
// as we are setting this module on left column, we are using this hook to load our module.
function hookLeftColumn($params)
{
return $this->display(__FILE__, 'fashion.tpl');
}
}
?>
Back office in prestashop
Back office is the prestashop admin panel. We can control the front office with it. So, we must know the features that prestashop has come up with.
Prestashop has the following section on the back office:
Catalog : use catalog to modify different properties of products.
• Category and subcategory: sort products by category. A product can be under multiple category and subcategories.
• Products: use this to add different properties of a product.
• Manufactures: manage manufactures.
• Suppliers: manage suppliers.
• Attributes : create and manage different attributes for different model of a products.
Customer: manage customers.
Orders: manage orders. You can use merchandising return and PDF invoice here.
Payments: under payment section , there are modules, taxes, currencies, discounts.
Shipping : There are carriers, countries, price ranges, weight ranges.
Preferences:
• Appearances: change header logo, metadata and favicon.
• Product settings: change product arrangement.
• Email settings: control email settings (it uses PHPMail() fucntion).
• Image settings: customize your image sizes.
• Database settings: configure database settings.
Tools:
• Employees: customize which users can enter back office.
• Profiles: create types of admin user.
• Permissions: determine which back office user has permission to enter which section.
• Translation: customize language files.
Prestashop has the following section on the back office:
Catalog : use catalog to modify different properties of products.
• Category and subcategory: sort products by category. A product can be under multiple category and subcategories.
• Products: use this to add different properties of a product.
• Manufactures: manage manufactures.
• Suppliers: manage suppliers.
• Attributes : create and manage different attributes for different model of a products.
Customer: manage customers.
Orders: manage orders. You can use merchandising return and PDF invoice here.
Payments: under payment section , there are modules, taxes, currencies, discounts.
Shipping : There are carriers, countries, price ranges, weight ranges.
Preferences:
• Appearances: change header logo, metadata and favicon.
• Product settings: change product arrangement.
• Email settings: control email settings (it uses PHPMail() fucntion).
• Image settings: customize your image sizes.
• Database settings: configure database settings.
Tools:
• Employees: customize which users can enter back office.
• Profiles: create types of admin user.
• Permissions: determine which back office user has permission to enter which section.
• Translation: customize language files.
Changing position of a module in prestashop
Prestashop is module based. It uses hooks to load the module. Not every hook can load every module.
To change the position of a module, go to the admin. Then module>positions. You can change position of the modules by clicking the edit button next to every module or you can click the transplant button. In the transplantation form, from the first list, we can choose the module that we want to move and from the second list, we will find the location where we will show the module. The third field accepts file names that will not show the module. These file’s path will be set from the base directory.
To change the position of a module, go to the admin. Then module>positions. You can change position of the modules by clicking the edit button next to every module or you can click the transplant button. In the transplantation form, from the first list, we can choose the module that we want to move and from the second list, we will find the location where we will show the module. The third field accepts file names that will not show the module. These file’s path will be set from the base directory.
Subscribe to:
Posts (Atom)

