Archive for the 'ajax' Category

Internet Explorer 8 (IE8) to adopt open W3C standards?

Wednesday, March 26th, 2008

Is there light at the end of the browser-hacking tunnel? I just read in SMH that IE8 will adopt open W3C standards by default (with an option to revert back to non-standard compatability modes to keep legacy systems built to support IE6 and IE7 up and running)…

Firstly, I am taking it with a grain of salt because after almost a decade of stupidity, I find it a bit hard to believe they are going to come full circle now. So I’m not throwing out our four-system browser-compatability (hacking) workstation just yet. But if it is true, then hallelujah!!!

These days we are spending (wasting) an absurd amount of time on browser compatability. In fact, for design-focussed clients, it’s such a problem that browser compatability is one of the earliest considerations we need to address in the design process, because there are simply so many pitfalls that a perfectly valid standards-based site concept may be a write-off in a good chunk of browsers.

Now, all we need to do is sort out standardize what’s happening on the javascript side of the equation and we’ll be taking fridays off (and probably half of thursday too)!

Newbie CakePHP Tips

Monday, February 25th, 2008

Here are a few things to keep in mind when learning CakePHP.

  • Learn Cake’s naming conventions. If you don’t understand them, you will not understand cake. Simple. e.g. If you have a field dropdown field in a form, in your view you should use $form->input(’featured_status’), and in your controller you could use $this->set(’featuredStatuses’, array(0=>’Not featured’,1=>’Featured’) ); The naming convention automatically converts between then, so your featured_status field will be populated with all the relevant featuredStatuses.
  • Lean what “Fat Models, Thin Controllers” means. http://www.littlehart.net/atthekeyboard/2007/04/27/fat-models-skinny-controllers/
  • You don’t strictly need a separate controller for every single model. Often, it’s much better to have few er controllers which store all related actions. This often makes it a lot easier to locate relevant code. (e.g. If you had a fruit model, as well as models for oranges, apples, and bananas, it could be good to just have a single fruits_controller, rather than separate controllers for each one.
  • Code newsting inside views should generally be based on the HTML structure, rather than PHP structure. e.g. You should indent code based on div’s, rather than php ifs and loops.
  • You should NEVER use straight database queries. You should learn how to use model associations (hasMany, belongsTo, etc) to perform your queries. Be sure to learn bindModel and unbindModel to perform special quieries -> they allow you to dynamically change your model behaviours, but conveniently, they only last for one query, so your other code will not be affected.
  • Use a small number of standard elements to build most of your site. Add optional parameters for adding headings, links, rows of data etc. The fewer generic elements you can use to build your ENTIRE site the better.
  • Beware the dreaded self-closing div tags < div / >. You must always have a separate end tag for divs. Don’t know why, it’s just the rules. e.g. < div>< /div>
  • When doing browser compatability, comment out each element in turn to identify which elements are causing problems. Also, use Firebug and Internet Explorer Developer Toolbar to ensure your div nesting is correct => incorrect nesting is a major source of browser bugs, because Firefox is a lot friendler than IE, so if you develop and optimise in Firefox you layout may look right, but it may actually contain structural errors which really need to be fixed, rather than just using unreliable browser hacks to hide the problems.
  • IE is particularly picky when using AJAX -> perform W3C Validation frequently on your html/css, because it will often pick these errors up for you! Rather than digging around in your code for an elusive missing tag or incorrect nesting order.
  • When using Enum values, use this method to populated your form fields (by adding it to your app_model.php): e.g. Controller code: $this->Event->getEnumValues(’approval_status’)); http://bakery.cakephp.org/articles/view/baked-enums
  • You don’t need to include all tables in your $uses array. If you include one table, you can uses any models that are associated with that first model by accessing the sub-model as a child of the first model. e.g. If your controller users Author, but you want to use a Book model, you could use the format: $this->Author->Book->findById($book_id)

HOME | CONTACT Copyright © 2008 Extro Interactive