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

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
主站蜘蛛池模板: 高碑店市| 孟州市| 枣庄市| 昆明市| 那曲县| 聂拉木县| 定结县| 信丰县| 德庆县| 芦山县| 微山县| 长顺县| 绥化市| 临潭县| 托克逊县| 灵川县| 合肥市| 页游| 汉川市| 屏南县| 司法| 泰兴市| 丰原市| 祁阳县| 涟水县| 福贡县| 黄浦区| 塘沽区| 新乡市| 义乌市| 白银市| 渝北区| 万载县| 肇庆市| 兴义市| 南开区| 富源县| 陕西省| 轮台县| 巴林右旗| 额尔古纳市|