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

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
主站蜘蛛池模板: 古浪县| 陈巴尔虎旗| 浪卡子县| 和平区| 兴业县| 兴宁市| 沧源| 多伦县| 辉县市| 凌云县| 汨罗市| 宁津县| 河间市| 台东市| 正定县| 上思县| 东乡族自治县| 临朐县| 河北省| 大渡口区| 南漳县| 兰考县| 庆安县| 临漳县| 仪陇县| 喀喇沁旗| 天等县| 南皮县| 信宜市| 讷河市| 班玛县| 大连市| 临武县| 侯马市| 胶州市| 凌云县| 正阳县| 电白县| 淮阳县| 阳朔县| 梓潼县|