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

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
主站蜘蛛池模板: 那坡县| 宽城| 东阿县| 绵阳市| 吉安市| 乡城县| 油尖旺区| 三明市| 金堂县| 若尔盖县| 遵义市| 张家界市| 吉首市| 连云港市| 汤阴县| 谢通门县| 中牟县| 郑州市| 滁州市| 南京市| 如东县| 华安县| 靖安县| 贡嘎县| 兴文县| 芦山县| 双城市| 大宁县| 元阳县| 三门峡市| 宿迁市| 同江市| 辛集市| 永川市| 壤塘县| 鹤壁市| 榆社县| 资阳市| 邮箱| 蒲城县| 酒泉市|