How are Areas found and updated by C5?

Permalink
I'm a little fuzzy on understanding how Areas that I add to my theme templates are "found" and updated by C5. I see that they work instantly, like if I add a new area, it's immediately available when I visit a page using that template. I'm just wondering more about situations where areas change. Like say you're trying out different themes. One has 4 areas in a page template. Then you switch to one with only 3 areas. What happens to that other area and any content in it? Is it lost, is there a way to retrieve it? Will it reappear if we switch back to another theme with that given area?

Also does the name of the area really matter to C5? If I 2 themes with different area names, can they work interchangeably?

I realize I could test some of these things myself and I probably will eventually but if anyone can save me some time and point to any existing materials on this it would be helpful. Of course I've the basic introductions to area, it's just they don't get into the mechanics or behind the scenes work that C5 does with them.

Thanks.

 
bbeng89 replied on at Permalink Reply
bbeng89
Hi Goldhat,
Concrete5 pulls the content for the area based on the area name. This is why there are recommended guidelines on how you should name your areas. You can check out the theme standards page here for more info on that:http://www.concrete5.org/documentation/developers/pages/themes-2...

So say you have a theme with a full width page type, a left sidebar, and a right sidebar. If you name the main content area "Main" then the left content area "Left" and right content area "Right" then you are going to lose any content added to the sidebar when switching between the left and right sidebar page types. Instead, I would just name the sidebar area "Sidebar" so that if you switch from a right or a left page type it will still display your content since it is just in the "Sidebar" area.

If you do switch to a theme that uses different names for its areas your content will not be lost. It will come back if you just switch back to the old theme.

I hope that helps clear things up. If anything is still fuzzy just let me know.

Blake
goldhat replied on at Permalink Reply
So it sounds like C5 isn't really aware of what areas are in use, it doesn't say parse the areas and then keep track of which Page Types are using which areas? Instead it just responds the use of new Area, and loads the blocks assigned to the area. That's okay I suppose but the issue I'm finding is when I'm making a StartingPoint, the XML export of the Pages has areas that no longer exist (that used to exist) and has blocks that no longer exist, etc. etc. So basically C5 doesn't seem to "clean up" areas, because it doesn't even realize they exist. So to really get a clean export, a developer might have to go through the database and manually delete from some of the tables that hold area information.

Currently I have added a Global Area to a template, and it's resulted in very strange behavior. In edit mode the area shows no blocks in the area. After saving the page, 2 blocks appear. If I hit refresh (out of edit mode) 2 blocks appear. Hit refresh again, no blocks in the area. I've tried clearing cache, no change. This is the region code below.

<div id="headerGlobalArea">
         <?php 
         $a = new GlobalArea('HeaderGlobal');
         $a->display($c); 
         ?>
      </div>
    <div id="headerArea">
         <?php 
         $a = new Area('Header');
         $a->display($c);
         ?>
      </div>
mhawke replied on at Permalink Best Answer Reply
mhawke
That behavior is caused by having a Global Area by the same name as some theme used to have a regular area. Huh?

Basically try renaming your Global Area to a name that you know never existed in any other theme you've used. There's a bug report on it but it apparently hasn't been fixed yet.
goldhat replied on at Permalink Reply
Ahaaah and you are right of course when I went to add that GlobalHeader area at first I forgot to put GlobalArea() and used Area() instead. Thanks for solving the mystery for me mhawke.

I'm thinking we need a "clean-up dead areas" utility tool. So that when you're adding/changing areas, you can full blast away the database records associated with an area no longer in use. Because you know the XML import looks for Page references, how it lists <area name="theArea"> with all the blocks in that area? Well if you stop using an area, any blocks in that area still get exported, and then that gets included in a StartingPoint import file. It's messy though I'm not sure it break anything on the import.
mhawke replied on at Permalink Reply
mhawke
Versioning trumps StartingPoints. All the dead stuff is left there to make sure versioning works. I've gone in to fix some sites that have 300-400 versions of their main page back until 2009. Yikes. What really needs to happen is that when you run the 'Delete old page versions' job, c5 needs to root through things and delete the dead weight then.
goldhat replied on at Permalink Reply
For reference sake if you make a global area with the same name as a previously existing regular area there will be entries in the following tables (in case you wanted to blast them area for a fresh start). In my case I'm kind of insistent that my area will be called HeaderGlobal :)

Stacks
PagePaths (stores the stack path)
Collections (chandle with name of the area)
CollectionVersions
CollectionVersionBlocks
CollectionVersionBlockStyles
Areas (in this case I found 3 records with same arHandle)