concrete5 also makes it easy to delete pages from the sitemap.
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
.
We will permanently delete the about us page and all of its child pages. The steps are as follows:
First, load the page that you wish to delete. We will delete a dummy page.
$page = Page::getByPath('/delete-me');
Call the
delete()
function on thePage
object.$page->delete();
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.
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();