Update Areas in Code

Permalink 1 user found helpful
I'm adding blocks programmatically to a pagetype default during package install. The issue is when I add a CoreAreaLayout block, the new areas with column identifier such as "Main : 34" are not immediately created. So when we add blocks into the newly created area columns, they are available later, but only seem to become active as a page default after we visit the page default page. This behavior doesn't seem unique to pagetype defaults, any collection seems to work that way. The result is when we make pages, the pagetype default blocks are not included. Yet later after visiting the pagetype default, suddenly the blocks are available and then future pages created will have the default blocks.

Looking at the database table "Areas" I'm seeing that there is a delay in creating the actual area record. The area record is only created when the page with a new area is visited.

Is there some method that handles this which we can fire to force an update of all areas on a page? I looked at the collection class, I see methods involving cache/rescan but none seem to affect areas specifically.

 
goldhat replied on at Permalink Reply
Found I could force the update of areas by calling new Area( $areaName ) after creating the CoreAreaLayout.
hurged replied on at Permalink Reply
It really was so helpful for me. Thanks