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

Updating a page type

Updating page types is very similar to creating a page type as discussed in the previous recipe.

How to do it...

First you will need to load an existing page type. You will need to pass in the same data array when updating page types as you would when creating them. The steps are as follows:

  1. Open /config/site_post.php in your code editor.
  2. Declare the old handle and the new handle variables.
    $handle = 'page_type_handle';
    $newHandle = 'new_handle';
  3. Define the new $data array with the new handle and new name.
    $data = array(
      'ctHandle' => $newHandle,
      'ctName' => 'New Name'
    );
  4. If the page type exists, update it.
    $pageType = CollectionType::getByHandle($handle);
    if ($pageType) {
      $pageType->update($data);
    }
  5. Verify that the page type was updated by visiting /dashboard/pages/types in your concrete5 website.

How it works...

concrete5 will update the record in the database for the loaded page type. The Master Collection page is not updated when this function is called. You also cannot pass a packaged object to the update function, as that is only necessary when first creating a page type.

See also

  • The Creating a page type recipe
  • The Deleting a page type recipe
主站蜘蛛池模板: 临高县| 江津市| 昭苏县| 澜沧| 小金县| 临澧县| 无锡市| 延庆县| 绵阳市| 天长市| 扶风县| 罗山县| 巴马| 垦利县| 民勤县| 繁昌县| 闻喜县| 合肥市| 南皮县| 德清县| 赤水市| 永丰县| 夏邑县| 雅安市| 奇台县| 福清市| 肇庆市| 云龙县| 前郭尔| 苍南县| 凤台县| 通化县| 交城县| 大庆市| 石嘴山市| 绥江县| 华容县| 南靖县| 珠海市| 高安市| 东光县|