How to Rename an Area already in use.

Permalink 4 users found helpful
I have created Page Types with Areas and have pages which use these. I would like to rename an area, but of course when I do this existing content is no longer displayed.

I could add a block with the new area and copy the content to it, however I'd much prefer to rename the area used by the existing blocks so the content is kept.

I can't see a way to do this in C5 itself. Maybe it can be done at the Database level using phpMyAdmin!

This isn't a big deal, but would be nice to be able do.

Neville

nevf
 
synlag replied on at Permalink Best Answer Reply
synlag
Use SQL Buddy package or phpmyadmin:

UPDATE Areas
SET arHandle = "Content"
WHERE arHandle ="Main";

Don't forget to change the area name in your theme.

--ron
nevf replied on at Permalink Reply
nevf
Thanks Ron, I thought something like that would do it. And thanks for the mention of SQL Buddy, which I'd never heard of and will have to try.

Neville
Hackopotamus replied on at Permalink Reply
Hackopotamus
I think you need to do this actually.

UPDATE areas SET arHandle = 'NewName' WHERE arHandle = 'OldName';
UPDATE collectionversionblocks SET arHandle = 'NewName' WHERE arHandle = 'OldName';
UPDATE collectionversionblockstyles SET arHandle = 'NewName' WHERE arHandle = 'OldName';
keeasti replied on at Permalink Reply
keeasti
This was very useful
Thanks!
AccountDisabled replied on at Permalink Reply
Oooh boy this procedure is no fun for a site with a lot of pages. Useful though.

Here are my queries in case they help anyone else. In these examples I am renaming a content area called 'Content' to 'Main'.

UPDATE Areas SET arHandle = 'Main' WHERE arHandle = 'Content';
UPDATE CollectionVersionBlocks SET arHandle = 'Main' WHERE arHandle = 'Content';
UPDATE CollectionVersionBlockStyles SET arHandle = 'Main' WHERE arHandle = 'Content';
UPDATE CollectionVersionAreaLayouts SET arHandle = 'Main' WHERE arHandle = 'Content';


Our site also had layouts so then I looked for those with the following queries.

SELECT * FROM Areas WHERE arHandle LIKE  'Content :%';
SELECT * FROM CollectionVersionBlocks WHERE arHandle LIKE  'Content :%';
SELECT * FROM CollectionVersionBlockStyles WHERE arHandle LIKE  'Content :%';
SELECT * FROM CollectionVersionAreaLayouts WHERE arHandle LIKE  'Content :%';


Depending on what you find you may need to run additional updates like...

UPDATE Areas SET arHandle = 'Main : Layout 1 : Cell 1' WHERE arHandle = 'Content : Layout 1 : Cell 1';
UPDATE Areas SET arHandle = 'Main : Layout 1 : Cell 2' WHERE arHandle = 'Content : Layout 1 : Cell 2';
UPDATE CollectionVersionBlocks SET arHandle = 'Main : Layout 1 : Cell 1' WHERE arHandle = 'Content : Layout 1 : Cell 1';
UPDATE CollectionVersionBlocks SET arHandle = 'Main : Layout 1 : Cell 2' WHERE arHandle = 'Content : Layout 1 : Cell 2';
UPDATE CollectionVersionBlockStyles SET arHandle = 'Main : Layout 1 : Cell 1' WHERE arHandle = 'Content : Layout 1 : Cell 1';
UPDATE CollectionVersionBlockStyles SET arHandle = 'Main : Layout 1 : Cell 2' WHERE arHandle = 'Content : Layout 1 : Cell 2';
UPDATE CollectionVersionAreaLayouts SET arHandle = 'Main : Layout 1 : Cell 1' WHERE arHandle = 'Content : Layout 1 : Cell 1';
UPDATE CollectionVersionAreaLayouts SET arHandle = 'Main : Layout 1 : Cell 2' WHERE arHandle = 'Content : Layout 1 : Cell 2';


Thanks to synlag and Hackopotamus for the original queries.

Cheers!
VonUniGE replied on at Permalink Reply
If you want to be sure to not forget anything you can list all tables with a column named arHandle.

SELECT TABLE_NAME FROM information_schema.columns WHERE table_schema = 'concrete5' AND COLUMN_NAME = 'arHandle'

For concrete 5.7.5.6, the tables to update are :

AreaPermissionAssignments
Areas
CollectionVersionAreaStyles
CollectionVersionBlockStyles
CollectionVersionBlocks
CollectionVersionBlocksOutputCache
PageTypeComposerOutputBlocks

This is a dangerous procedure, if you have a better way to rename an area, please share.
JohntheFish replied on at Permalink Reply
JohntheFish
There has been some discussion of adding core functionality to help resolve the problem, but as yet no solution.

https://www.concrete5.org/community/forums/5-7-discussion/page-type-...

https://github.com/concrete5/concrete5/issues/195...