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

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
主站蜘蛛池模板: 沛县| 子洲县| 湘西| 中超| 新密市| 梁河县| 陵水| 筠连县| 延庆县| 溆浦县| 红桥区| 霍邱县| 兴安县| 潼关县| 乌鲁木齐县| 岳普湖县| 安图县| 连江县| 阿坝| 沙雅县| 墨江| 安陆市| 大竹县| 大英县| 濮阳县| 上林县| 乐都县| 西畴县| 阿坝县| 渝北区| 巴中市| 上高县| 洞头县| 卓尼县| 新乡县| 磐石市| 信阳市| 邻水| 青浦区| 仁怀市| 太康县|