- 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
- 自己動(dòng)手實(shí)現(xiàn)Lua:虛擬機(jī)、編譯器和標(biāo)準(zhǔn)庫(kù)
- R語(yǔ)言數(shù)據(jù)可視化之美:專業(yè)圖表繪制指南
- Dependency Injection in .NET Core 2.0
- Getting Started with Greenplum for Big Data Analytics
- Learning Apache Karaf
- Service Mesh實(shí)戰(zhàn):基于Linkerd和Kubernetes的微服務(wù)實(shí)踐
- Mastering AWS Security
- 軟件工程基礎(chǔ)與實(shí)訓(xùn)教程
- Mastering Docker
- Flink技術(shù)內(nèi)幕:架構(gòu)設(shè)計(jì)與實(shí)現(xiàn)原理
- UX Design for Mobile
- Solr權(quán)威指南(下卷)
- 你必須知道的.NET(第2版)
- 美麗洞察力:從化妝品行業(yè)看顧客需求洞察
- 趣學(xué)數(shù)據(jù)結(jié)構(gòu)