Creating Custom Widgets in Magento E-commerce Software

The Magento Community Edition Version 1.4 facilitates the use of custom frontend extensions by introducing a new concept of customizable widgets, which can provide more control over the frontend behavior and visual block placement to store owners.


Here I am assuming that magento e-commerce software is already installed on your site. If magento e-commerce software is not installed on site then please go to http://www.magentocommerce.com and install it on your site. Follow the the installation guide: http://www.magentocommerce.com/wiki/installation_and_configuration/magento_installation_guide for installation of magento e-commerce software.


We will write a customise widget which will display Polls which are created on the requestio.com. After creating this plugin, user will be able to see the polls you created on requestion.com and they also will be able to vote on those polls.


Add widget instances in the admin panel:

For creating customize widget in magento we have to do 2 steps.

  • Add Statics blocks in admin panel CMS > Static Blocks
  • Then use these static blocks on pages CMS > pages by inserting widgets on these pages.


Add Static Block – CMS > Static Blocks

By using static blocks you are able to create content for category pages, allowing you to showcase items and promotions instead of just displaying the grid list of products.

To create a static block go to CMS > Static Blocks, then select Add New Block.

magento creating custom widget

In this case we are going to create a block for showing the polls from requestio.com.

We enter the Block title, for internal use, and the identifier, which will create the URL for this page.

We then select the store we want to use the Block on, in this case all stores, and set the Block to enabled. Once that is done we enter our content in an HTML Format and select Save Block.

We have used following html code in content of our static block –

<div id="pollhere">poll will generate here</div>
<script>var pollID=77;</script>
<script src="http://app.requestio.com/poll_js/riop.js"></script>

And we have given the Block title as, “Custom poll widget”.

Now move to second step :

Add widget instances in the admin panel using content editor

Let’s go to CMS > Pages in the admin panel and add a few widget instances on the homepage (select homepage from the list of CMS pages, click the “Content” tab on the left).

“Add Widget” button in WYSIWYG mode:

magengo create customize widzet

Widget selection and configuration popup:

magento create static blocks

Widget in the CMS page content in the WYSIWYG and plain text mode:

Creating Custom Widgets in Magento E-commerce Software


Creating Custom Widgets in Magento E-commerce Software


Check over the frontend

magento create customize widget


The requestio poll widget(Who will will the T-20 world cup 2010) is shown in the right hand side of the page in the above picture.

If user selects any country and click on vote button then following output will be displayed in the “Requestio poll widget”.

magento create customize widget



Codeigniter: Separating read and write operation for scaling MySQL

Generally websites average a ratio of 9:1 or more for reads:writes for their applications which makes MySQL replication as one of the ways to scale you web application. The simplest configuration is to separate reads and writes with all the reads coming from the slave servers.

We can implement this in codeigniter using database


Simple tips for mysql optimization

MySQL is interpreted from right to left so you should put the most significant limiters as far to the right as possible.
Only select fields you need, instead of selecting * (everything).
Don’t put things that changes very rarely in the database, instead put it in a global array in some include file.
Use


Memcache – Server Side Caching

What is Memcached?

Free & open source, high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.
Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering.
Memcached is simple yet


Cross-site Scripting

Cross-site Scripting (XSS) is an attack technique that involves echoing attacker-supplied code into a user’s browser instance. A browser instance can be a standard web browser client, or a browser object embedded in a software product such as the browser within WinAmp, an RSS reader, or an email client. The code itself is usually written


Comet : http streaming

I really like Gmail. In fact, I LOVE it, and  I am pretty sure you too. It is simple, slick, elegant yet powerful and rich with functionality.  Many of us rely on gmail for our daily business tasks.
So what’s special about gmail? It’s easy to use interface, slick design, and


Speeding Up Your Web Site

What makes a website good? Is that looks and presentation created by combination of some cool CSS and images? Or is it it’s pure functionality, what features it provides, it’s user friendliness, never mind the looks? Well, for some people, looks matters while other prefers it’s functionality. But in reality, a web developer really has


SEO : Best Practices

There are some basic rules for SEO which if followed, can assure your site a good rank in a search engine. These are very basic and easy to follow.

Relevant keywords – Use a keyowrds in <meta> tag that are only relevant to your site. The keywords in meta tag must appear anywhere


SQL Injection

A SQL injection attack consists of insertion or “injection” of a SQL query via the input data from the client to the application. A successful SQL injection exploit can read sensitive data from the database, modify database data (Insert/Update/Delete), execute administration operations on the database (such as shutdown the DBMS), recover the content of a


SOAP – Simple Object Access Protocol

Soap is a simple XML based protocol to let application exchange information over HTTP.
Or more simply: SOAP is a protocol for accessing a Web Service.
Installation (PHP 5 have support for SOAP classes)
PHP.INI Settings
Just put
extension=php_soap.dll
Note : Make sure that extension_dir path is mentions correctly
oap.wsdl_cache_enabled=”1″
soap.wsdl_cache_dir=”/tmp”
soap.wsdl_cache_ttl=”86400″
Why SOAP?
It is important for application development to allow Internet communication between programs.
Today’s