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

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
主站蜘蛛池模板: 应城市| 黎城县| 安图县| 安庆市| 灵璧县| 南岸区| 长泰县| 福安市| 响水县| 阜阳市| 循化| 临桂县| 屯昌县| 青州市| 无棣县| 临漳县| 平山县| 扬州市| 禄丰县| 长白| 许昌市| 富平县| 金湖县| 甘泉县| 射阳县| 会泽县| 肥乡县| 耿马| 河北省| 永寿县| 镇安县| 合水县| 东城区| 太谷县| 滨海县| 花莲县| 澄迈县| 潜江市| 鄂托克前旗| 宣城市| 万源市|