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

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
主站蜘蛛池模板: 塔河县| 新巴尔虎右旗| 汽车| 来凤县| 洪雅县| 佛坪县| 达孜县| 芒康县| 广南县| 阿坝县| 井冈山市| 海盐县| 张家川| 腾冲县| 封丘县| 香河县| 道孚县| 武清区| 项城市| 南郑县| 卢龙县| 天水市| 浦北县| 中阳县| 涟水县| 长子县| 成武县| 德钦县| 乌拉特中旗| 吴忠市| 大安市| 濮阳市| 兴山县| 新竹市| 建德市| 鱼台县| 营山县| 桂平市| 桑植县| 民县| 米泉市|