Refactor PHP layout because DRY