- concrete5 Cookbook
- David Strack
- 202字
- 2021-08-13 16:15:59
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:
- 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();
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
- JSP網(wǎng)絡(luò)編程(學(xué)習(xí)筆記)
- 算法精粹:經(jīng)典計(jì)算機(jī)科學(xué)問題的Java實(shí)現(xiàn)
- VMware vSphere 6.7虛擬化架構(gòu)實(shí)戰(zhàn)指南
- Object-Oriented JavaScript(Second Edition)
- Getting Started with SQL Server 2012 Cube Development
- concrete5 Cookbook
- Learning SciPy for Numerical and Scientific Computing(Second Edition)
- Visual FoxPro程序設(shè)計(jì)習(xí)題集及實(shí)驗(yàn)指導(dǎo)(第四版)
- ScratchJr趣味編程動(dòng)手玩:讓孩子用編程講故事
- Geospatial Development By Example with Python
- Node.js開發(fā)指南
- Red Hat Enterprise Linux Troubleshooting Guide
- Learning Nessus for Penetration Testing
- C#面向?qū)ο蟪绦蛟O(shè)計(jì)(第2版)
- 大學(xué)計(jì)算機(jī)應(yīng)用基礎(chǔ)(Windows 7+Office 2010)(IC3)