- concrete5 Cookbook
- David Strack
- 165字
- 2021-08-13 16:15:56
Deleting a page type
In addition to adding and editing page types, you can also delete them.
Getting ready
Since deleting page types is a destructive action that is irreversible, it's a good idea to create a dummy page type with the handle of delete_me
for this exercise. We will also continue using site_post.php
to execute arbitrary code.
How to do it...
The steps for deleting a page type are as follows:
- Open
/config/site_post.php
in your preferred code editor. - Define the handle of the page to be deleted.
$handle = 'delete_me';
- Load the page type by its handle.
$pageType = CollectionType::getByHandle($handle);
- Now, delete the page type.
$pageType->delete();
How it works...
The delete()
function deletes the page type, the Master Collection, and all of the pages that use it. Use this function very cautiously, as once the data has been deleted, it cannot be recovered (unless you have a backup copy of the site's database).
See also
- The Getting a page type by its ID recipe
推薦閱讀