stefan's blog

Using an alternative pagelayout template in ezpublish

I was trying to not use the site's default layout template for a popup iframe (using fancybox), as I didn't need headers/footer information.

To do this, create a new template file called, for instance popup_pagelayout.tpl

and in the link to your view, use prepend the following: "/layout/set/popup/" to your existing "module/view". What this does it tell EZ that you are using the popup template file, then it continues to execute your module as before.

EZ publish displaying php code in firefox above content

Ran into an issue with ezpublish displaying the code for a module (in firefox) instead of running the module. It only did so on one server, turned out that the fix was to allow php short tags in php.ini

ez publish running over/out php memory limit

If you have a script to download all users or something with lots of rows and are running out of memory, even after having increased the limits a few times, then you may want to throw this into one of your loops:


to free up some memory caching that ez does.

Turning off order confirmation email in EZ publish

If you find yourself receiving confirmation emails you can either override them to make them display what you want by adding an override on 'shop/orderemail.tpl' or you can turn them off entirely by adding


to your site.ini file.

ezpublish login/logout redirection

Searching for a while, I found hidden variable on login forms called RedirectURI is used to send someone somewhere after login. There isn't such a variable that you can append to a logout, but apparently you can add an ini file variable

such as


You could then have it go to a page of your choosing, but by that time your session will have been unset, so its not terribly useful besides sending them to the home page.


I've noticed that more and more websites are being run powered by django. I ignored the ruby on rails revolution and did quite well with php. However, having worked on several large installs it seems as if php is often not up to the task. It seems woefully inefficient to have a web application (they aren't scripts anymore) without state, so everytime it needs to hit disk to load a session or the database to re-run hundreds of initialization queries each time. One can just throw more hardware are it, but perhaps there should be state.


It seems painstaking to find any kind of useful demos and howtos for ezpublish. I'm not entirely sure of why the community of developers around it don't post any information, but it certainly is an issue. It makes starting out as a developer quite tricky and a laborious process of trial and error instead of spending time coding.

Updating DYNDNS from linux box behind router

So a few of my clients have routers that don't talk to DYNDNS or if they do seem to be pretty rubbish at it. I wrote the following php script which relies on the dyndns client. it does some screen scraping.

$temp = file_get_contents(""); //get html with IP address

$pos = strpos($temp,"Address:") + 9; //find starting position

$pos2 = strpos($temp,"/body") - 1;

$ip = substr($temp,$pos,$pos2-$pos); //get IP address

system("/sbin/ifconfig eth2:1 $ip"); //set it to a virtual device

Using Mencoder to compress and shift formats

I googled a bit and found this article. I'm reproducing it here to keep the text in case it ever disappears from the internet, just because every few months or so I'm in need of a good overview of mencoder flags. This seems to have quite a few use cases. Here's the original:

and here's the text:

Casting a character column to integer on sort in postgres

One of my clients had a field that they entered session numbers into, but sometimes they had session 101a and 101b so it was a varchar field. However when sorting by it, 1001 would show up before 101 as postgres was using a character sorting algorithm.

This was the original SORT BY session_number ASC and I googled a bit and found that you can cast within postgres so now it works with SORT BY (session_number::text)::integer ASC.

It works well until it finds an entry which isn't an integer, then it complains. Will investigate further options.