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 [...]
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.
In: PHP
4 Nov 2010This is an example how PHP download counter could be made. This is just a basic but still functional example. So, in order to make a download counter we shall need three scripts: download_file.php download_count.php show_download_number.php First part of our PHP download counter script will be replacing actual file that should be downloaded, and will [...]
In: PHP
27 Oct 2010Script authors: Drasko Gomboc and Sankovic Marko. When running automated backup it is a good practice to save exact time when you made backup in your file name. This snippet shows you how to automatically add date and time before extension in your file name. 1 2 3 $filepath = ‘/backup/folder/drasko_gomboc-and-sankovic_marko.txt’; $new_filepath = preg_replace("/(\.[^\.]*)$/", date(’-Y-m-d-h-i-s’) [...]