The story starts as always with the user, yes! … that villain, let’s suppose that he has committed the inexcusable crime of clicking the submit button of a form. The poor browser that struggles to keep opened the 100 tabs without crashing begs the operating system to open a magic portal known by some scholars as TCP connection. At the gates o internet he meets the omniscient wizard of DNS that indicated the path to the castle where the WebServer reside. It wanders form router to router and hub to hub and almost when he lose the hope and his TTL finally he found the castle. Here the WebServer listen his web request and consults the infallible code of his sanctity THE Programmer. After thousand CPU cycles and couples of OS interrupts the webrequest is found as nonconforming with the teaching of code so an error is handed as response. Tired and with broken spirit the the browser displays the error to his master the user.
Continue reading »
Sencha touch is providing all the controls that you need to create any mobile application, but still what happens if you want to build your own custom component, well those nice guys that have invented the framework came with a solution on this problem, they created the XTemplats. In a few words this feature allows you binding stores from custom piece of HTML. This seams to solve any problem but what happens when you want to add a x-button or x-label inside the xtemplate. Well the documentation it says you can’t, I have struggled with this limitation and came up with a workaround. What I did was to dynamically create the sencha comportment and inject them using DOM selectors. This is depicted in the following lines of code
A lot of people contacted me about the Magento product chooser sample that I have wrote a while ago. Most of them complained they haven’t succeed to make it work. So to help them I have forked on github a minimal working example. If you are still interested you can download it from Magento product selector I hope this sample had saved you in a way or another from hours of frustration and revers-engineering on Magento source code.
Location, location, location yeah !!! every app nowadays has to do something with the user golocation, event if it searches for pubs nearby, a place to rest or just a location to get drunk.
Is really fun to work with Google Maps, all you need is a piece of JavaScript. First you have to take care to include the script that will load the Google Maps API in you’r page to do that add the following line of code: Continue reading »
jPlayer is really grate because it is easy to integrate, well good documented, it has support for almost all browsers even for iOS and Android. Still it has some issues on Android; in my case I have experienced them on Android 2.3. It happens that on using the play function the player crash and stop working until you refresh the page, this is happening because it tries to read the media duration before the media header is fully loaded. I have solved this problem by directly hacking the code and added a delay on play function. The fix may look like:
play: function(time) { time = (typeof time === "number") ? time : NaN; // Remove jQuery event from click handler if(this.status.srcSet) { if(this.html.active) { var __player=this; var interval=setTimeout(function(){ // Ugly fix for Android, but hell yeah... it works __player._html_play(time); clearTimeout(interval); },4000); } else if(this.flash.active) { this._flash_play(time); } } else { this._urlNotSetError("play"); } },
Continue reading »
I love working with iframe content loading… noo no way, I actually hate it, but there are situations when loading the content inside the iframe is the only viable technical solution. I am sure you have use it before and maybe you have asked yourself how to add something like a loding animation while the frame is loading. I will provide a example but today I am fling lazy so I will use jQuery, the code should be something like:
There is no point in explaining what is MVC, if you don’t already know what is MVC well dear, then you got an issue … trust me I am an engineer
. OK, now lets see how do we create our models in Sencha and fill the with information form back-end. I will create a models that holds the information related to user contact information. To keep this minimal the model could be something like:
** * Model mapping the contact details */ Ext.regModel('ContactDetails', { //Contact website { name : 'website', type : 'string' }, //Twitter account { name : 'twitter', type : 'string' } //TODO Add more details :), I am lazy } ** * Model mapping the contact structure */ Ext.regModel('Contact', { //Contact name { name : 'name', type : 'string' }, //Contact email { name : 'email', type : 'string' }, //Contact details // Mapping Contact details model { name : 'detail', type : 'ContactDetails' }, }
In the previous article have showed you how to integrate the almighty Doctrine ORM in Zend. But I haven’t mentioned nothing about the magic of this wonderful framework CLI.
I suppose that you have already done all the required magic incantations to integrate Doctrine in Zend, now what you are supposed to do next is to create in your Zend project a folder called bin and add doctrine.php file with the following content : Continue reading »
Zend is, in my opinion, the best PHP framework ever it has a lot of really nice useful stuff, but it doesn’t have a build in ORM. I have recently worked with Doctrine ORM 2.0 that is a superb ORM framework, wrote on PHP 5.3 can be easily integrated in Zend.
So, lets keep it short,
1. download and copy the doctrine framework to the library folder
2. add the following lines to the applicaion.ini:
doctrine.connection.host = 'mysql db host' doctrine.connection.user = 'mysql user' doctrine.connection.pass = 'mysql pass' doctrine.connection.driv = 'pdo_mysql' doctrine.connection.dbname = 'mysql databse' doctrine.path.models = APPLICATION_PATH "/models/" doctrine.proxyNamespace='\Proxies' doctrine.proxyPath=APPLICATION_PATH . '/models/Proxies' doctrine.modelsPath= APPLICATION_PATH . '/models'
I’ve been working for a while with Kohana 3 and really enjoin the features provided by it such as HMVC, ORM and caching, features that makes our live as developers really easy allowing us to create really nice pink application. But, yeah … there are no pink ponies jumping on rainbows, or are there any ?? I am talking about views from Kohana, I really don’t like the way they mix HTML markup and PHP code it is really annoying when you see a foreach loop and inside it some echo, I am sure that you really understand what I mean. But tanks God there are some really smart people that were thinking about this long time before, so this people have invented something that we are calling Smarty. Smarty is a template engine, a template engine’s life purpose is to provide a clear separation between the application business logic and the way the data presentation, or you know…in ancestor time this was called design right ?. Well that is necessary because there are two main categories of players: developers and designers and each loves only their own toys. This article is not aiming to learn you advanced topics about Smarty, I suppose that if you are instead of it you can ask the almighty Google about that.
I have wrote some glue code that make possible the utilization of the Smarty template engine in Kohana very simple and transparent, so you don’t have to change nothing in your existing application. All you have to do is to download the module form Smarty-views-for-Kohana repository, extract it in your modules folder and add the following line in your bootstrap.php on module loading section and you are ready to go.
'smarty' => MODPATH.'smarty', // Smarty views
So basically now you have finished, have fun with Kohana and Smarty.
