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

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
主站蜘蛛池模板: 开封市| 九江县| 桂东县| 临泉县| 五指山市| 平利县| 敦化市| 阿巴嘎旗| 友谊县| 榆树市| 法库县| 永和县| 游戏| 永仁县| 攀枝花市| 岢岚县| 栾川县| 湘乡市| 满城县| 高淳县| 保山市| 永新县| 兰溪市| 八宿县| 中山市| 中牟县| 固镇县| 精河县| 张家界市| 绍兴市| 达日县| 邯郸市| 祁门县| 澄城县| 榆林市| 永昌县| 永川市| 吉木乃县| 新竹市| 兴城市| 靖宇县|