Skip to content →

Tag: layout

CakePHP: Kenapa layout masih tak tukar?

Kalau malas asik nak declare layout di cakephp, aku akan guna code macam ni.

/* before Render */ function beforeRender() { parent::beforeRender(); $this->layout = 'plugin'; .... }

lepas tu aku nak tukar stail layout, misalnya nak guna layout “ajax”. jadi aku declare macam ni..

/* children */ function children($id = null) { .... $this->layout = 'ajax'; }

tapi tak jadi!? kenape? perasan function beforeRender tu?

/* before filter */
function beforeFilter()
{
parent::beforeFilter();
….
$this->layout = ‘plugin’;
}

baru jadi! sebab beforeRender akan override balik variable sebelum render! sebab tu tak jadi.

One Comment