- concrete5 Cookbook
- David Strack
- 281字
- 2021-08-13 16:15:57
Updating an existing page
Updating pages is similar to creating them in that you must first pass in an associative array containing all of the data that you wish to update on the page.
Getting ready
In this recipe, we will be modifying a page with the path of /about
. We created that page in the previous recipe, but if it does not exist on your system, please adapt the code to your needs.
How to do it...
In this example, we will update the name of the About
page. The steps are as follows:
- First, we need to load the
Page
object by its path.$page = Page::getByPath('/about');
- Create an associative array with the data that you wish to update.
$data = array( 'cName' => 'About Our Company' );
- Pass the data array into the
$page
object's update function.$page->update($data);
- Output a success message and exit the process.
echo 'done!'; exit;
How it works...
The update
function updates the necessary tables in the database with the newly specified information. concrete5 will also rescan all permissions for this page and all of the related page paths. When the function is complete, the on_page_update
event is fired, which you can write custom code to listen to and perform custom actions when a page is updated. Listening to system events is covered in a later chapter.
There's more...
Just like creating a page, you will need to pass an associative array to the update()
function in order to update an existing page. You can use all of the fields specified in the previous recipe for adding a page, in addition to these other optional fields.

See also
- The Creating a page type recipe
- OpenStack Cloud Computing Cookbook(Third Edition)
- Java應用與實戰
- Design Principles for Process:driven Architectures Using Oracle BPM and SOA Suite 12c
- Python高級編程
- Java深入解析:透析Java本質的36個話題
- 編譯系統透視:圖解編譯原理
- Scientific Computing with Scala
- Asynchronous Android Programming(Second Edition)
- 精通Python自動化編程
- Access 2010數據庫應用技術實驗指導與習題選解(第2版)
- 現代C++語言核心特性解析
- 算法訓練營:海量圖解+競賽刷題(入門篇)
- MonoTouch應用開發實踐指南:使用C#和.NET開發iOS應用
- C/C++語言程序開發參考手冊
- Serverless從入門到進階:架構、原理與實踐