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

Deleting a page (and its children)

concrete5 also makes it easy to delete pages from the sitemap.

Getting ready

Deleting pages is a permanent destructive action. When experimenting with this code, it would be a good idea to create a dummy page with a path of /delete-me.

How to do it...

We will permanently delete the about us page and all of its child pages. The steps are as follows:

  1. First, load the page that you wish to delete. We will delete a dummy page.
    $page = Page::getByPath('/delete-me');
  2. Call the delete() function on the Page object.
    $page->delete();

How it works...

concrete5 will fire the on_page_delete event before any actual deleting occurs. After the event fires, the page (and all of its children) are deleted from the database. This operation is permanent, so it is important to make sure that you only delete pages when you are certain that they are no longer needed.

There's more...

If you don't want to permanently delete a page, you can move it to the Trash. As of concrete5 version 5.5, pages can be "temporarily" deleted and moved under a special internal page called the Trash.

$page->moveToTrash();

See also

  • The Getting a page by its path recipe
主站蜘蛛池模板: 鄂托克前旗| 响水县| 阳东县| 抚州市| 公主岭市| 原阳县| 吴桥县| 策勒县| 乐至县| 桐柏县| 靖江市| 集贤县| 法库县| 泾阳县| 黄平县| 宜丰县| 运城市| 顺义区| 札达县| 朝阳县| 宜良县| 乌拉特后旗| 吉安县| 商河县| 临清市| 嘉禾县| 嘉鱼县| 卓尼县| 万载县| 江华| 烟台市| 姚安县| 博野县| 望江县| 乌审旗| 台东县| 尖扎县| 建平县| 曲麻莱县| 盘锦市| 辛集市|