1st August
2011
written by Ricky Stevens

The context of this is actually for ACL, where I wanted to determine whether a use can view the link or not. I have seen other people extend the URL View Helper to do this which kind of works, but it just means the entire <a> tag has to be produced by the helper rather than the URL. This didn’t sit too well with me, so I settled for wrapping the <a> in a IF block. Within my templates I only use the route name, i don’t pass through the module/controller/action params to the URL helper, as it means refactoring modules and controllers is much easier, if the need were to arise. Due to this, I needed to fetch the Module name, Controller Name and Action name from the Route name. Simple eh?

Continue reading “Zend Framework – Get The Module, Controller and Action by Route Name” »

22nd June
2011
written by Ricky Stevens

When using technologies such as Zend Framework and Doctrine, some form of OpCode caching is a must. The average memory used per request with Zend Framework alone is ~30MB, which is a massive performance hit. Doctrine doesn’t fare much better either. My prefered caching mechanism is APC, but there are certain conflicts it has creates when using it with these technologies.

Continue reading “Zend Framework, Doctrine and APC” »

18th April
2011
written by Ricky Stevens

I’ve been using jQuery Sortable for quite a while over various projects, and I’ve never encountered any strange behaviour. On my current project however, I had used the jQuery UI Sortable to allow the client to re-order some elements within an HTML list. Oddly though, whenever you scrolled down the page to get to the list, and dragged an element, the offset of the dragged element went a bit mad and flew up the page!

Continue reading “jQuery Ui Sortable – Offset Bug” »

18th April
2011
written by Ricky Stevens

Zend Translate is a great piece of kit, allowing you to switch between translation adapters with the flick of a few keys. GetText is my sin of choice, and that is what I’ll be talking about here. GetText itself can scan over projects and pick up all the translations, and drop them into your PO files. This is fantastic, as long as you stick to the extremely strict methods that GetText defines. But if I’m using Smarty translation blocks, how do I get GetText to pick them up? Because am I hell adding them all in by hand!

Continue reading “Zend Framework – GetText, Smarty and Automatically Adding The Translations” »

7th January
2011
written by Ricky Stevens

Sounds easy enough really, or it should be anyway! When using a routes.ini with the Zend_Router, the concept is you only ever refer to the name of the route, rather than the URL itself. So if you have an awkward client that suddenly wants a URL changed on their website because their “SEO Expert” thought it might be a good idea, you simply change the url against that Route name, and the whole website updates to use this URL. Better than spending several hours going through every page on the website and updating each link manually!

Continue reading “Zend Framework – Get Route Name by URL” »

7th January
2011
written by Ricky Stevens

I’ve recently had a couple of requests for an example project using Zend ACL, so I thought I’d set one up really quickly. I have to say that a lot of credit goes to Dave Clarke who implemented most of the code here at work for our current project. Hopefully this short description, and the example install should help a few people out who are struggling with this largly undocumented ACL-shaped beast.

Continue reading “Zend Framework – Working ACL Example” »

6th January
2011
written by Ricky Stevens

Doctrine is a fantastic ORM, and it is my preference when developing any large scale PHP application. However it has some holes in the documentation that catch me, and I assume many others, out every so often. One of these little hick-ups in the documentaiton came when a colleague and I were attempting to do a deep copy or clone of a doctrine record with its loaded relationships. Simple according the documentation.

Continue reading “Doctrine – Deep Copying of Relationships” »

27th December
2010
written by Ricky Stevens

This plagued me for quite some time, and all I found by searching Google were answers that were either 100% wrong (and often idiotic), or people repeatedly saying “use wmode: transparent“. Yeah this is correct, but it didn’t fully accomplish the task at hand. After about 3 hours of searching and finding absolutely nothing of use, I started to do some proper R&D to create my own solution to this problem.

Continue reading “Overlaying Clickable Div Over Flash Movie” »

23rd December
2010
written by Ricky Stevens

A common technique I use in PHP is to cycle an array and remove the array items which aren’t required for my operation. For instance if I’ve got an array of questions, and I need to remove all the questions that are already answered, as well as removing the questions that have been disabled or are irrelivent for that user, I will go through the question array and unset() the array item. This will leave me an array with only the required questions. Simple enough really, but a side effect of this is that all of the array keys are now foobar’d, so we will need to rebuild the array keys.

Continue reading “PHP – Rebuild Array Keys” »

17th December
2010
written by Ricky Stevens

Today I was passed an article entitled CSS: CamelCase Seriously Sucks! by Harry Roberts, by the front-end developer at work. You guessed it, the article was about CSS Naming Conventions. And it also doesn’t take a genius to work out that Harry Roberts isn’t a massive fan of CamelCase. A summary of his article is that as CSS uses a hyphenated delimiter for all its properties (eg background-color, z-index) you should name your CSS elements in the same hyphenated system. This is a valid point, and at first glance is very logical. However, if you take a step back it might not actually be that practical.

Continue reading “CSS – Element Naming Conventions” »

Previous