In: PHP
2 May 2012Sometimes you need to get exact location by address entered by user on your website. Google Maps API offers a service that will return exact coordinate by the request you send it. See following snippet to see how to get coordinates from postcode or address by using Google Maps API. $address = ’124 Norfolk Street, [...]
In: PHP
9 Dec 2011When setting your Zend Form with Select field you don’t always wish to have label on that filed but rather “Select one” as a first option. Setting the required flag on Zend Select, or adding notEmpty validator won’t always work especially if your box is being populated dynamically. Let’s say you have something like this: [...]
In: PHP
23 Nov 2011PHP fluent interfaces have been around for quite some time. They are often used just for chaining methods of an object so that we get nice readable code. Good fluent interface takes a while to build, and will take some planning to make object methods work seamlessly. However, if you still haven’t experienced the PHP [...]
In: PHP
1 Oct 2011CSRF or Cross-Site Request Forgery is basically a way of requesting an unauthorized commands from a website by using an authorised user. For example: Let’s assume that you are logged in on your blog and I know that. I could then send you an e-mail with following content: <img src=”http://yoursite.com/?action=delete-article&id=12″ />. Although you wouldn’t see [...]
In: PHP
12 Apr 2011Have you ever wondered if you could let user see his website visits on his own admin page without having to leave backend of his system? I have… Actually – the CMS I made for my clients (written in Zend Framework) has this option for quite some time, and users love it. So – in [...]
Simple question that developers in Magento sometimes ask is: “How can I add custom attribute to customers when using Magento”. The answer is simple – it is shown in the snippet below. But before you use it lets imagine what we want to do… Lets say that we want to give discount to users that [...]
In: PHP
20 Jan 2011There is an easy way to get current domain name in Zend Framework. To get domain name in Zend Framework – use following snippet in your view file. echo $this->serverUrl();
In: PHP
29 Dec 2010Get number of Twitter followers using this PHP snippet is easy. Once you get all the data from Twitter, you just have to isolate followers_count. Besides followers count, you can extract following data as well: id name screen_name location description profile_image_url url friends_count created_at lang Now, finally, to get number of Twitter followers, use following [...]
Have you ever wondered how to display Magento static block inside your app/store? It is an easy task, so just use following snippet. First, you have to create your static block in Magento admin, and than use its name to load it in your web application. 1 2 $block = Mage::getModel(’cms/block’)->setStoreId(Mage::app()->getStore()->getId())->load("Magento_static_block_name"); echo $block;
In: PHP
16 Dec 2010So, almost every website needs contact form – is it a real contact form or just a feedback from your users. We need to make a contact form as easy to deal with as possible.