官术网_书友最值得收藏!

  • 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:

  1. Open /config/site_post.php in your preferred code editor.
  2. Define the handle of the page to be deleted.
    $handle = 'delete_me';
  3. Load the page type by its handle.
    $pageType = CollectionType::getByHandle($handle);
  4. 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
主站蜘蛛池模板: 扶风县| 城固县| 乌拉特中旗| 金门县| 吴桥县| 栾川县| 镇雄县| 临沭县| 深水埗区| 高邮市| 湖北省| 长沙市| 南丹县| 古蔺县| 惠安县| 饶河县| 四子王旗| 沅陵县| 广昌县| 佳木斯市| 浮山县| 济阳县| 武义县| 宁强县| 龙江县| 万源市| 呼伦贝尔市| 蕉岭县| 呼和浩特市| 任丘市| 兴安县| 同江市| 六安市| 辉县市| 黄山市| 广昌县| 马山县| 那曲县| 赫章县| 樟树市| 英山县|