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

Getting a page type's ID

Once a page type has been loaded, we can get different information from it. Sometimes, if a page type is loaded by its handle, or if it was provided from another function call, developers will need to get the page type's ID from an existing page type object. In this exercise, we will load a page type by its handle, and then find out the ID of the page type.

Getting ready

We will be loading a page type with a handle of right_sidebar in this example. If that page type does not exist in your concrete5 system, feel free to adapt this recipe to suit your specific situation.

How to do it...

The steps for getting a page type's ID are as follows:

  1. Open /config/site_post.php in your code editor.
  2. Load the page type by its path:
    $pageType = CollectionType::getByHandle('right_sidebar');
  3. Get the ID from the page type.
    $id = $pageType->getCollectionTypeId();
  4. Dump the page type ID (we are using the custom debugger explained in this chapter's introduction).
    my_debug($id);

How it works...

Once the page type object is loaded, developers can call a number of functions to retrieve data from it, including the numeric ID.

See also

  • The Getting a page type by its handle recipe
主站蜘蛛池模板: 罗江县| 昭觉县| 昭平县| 墨竹工卡县| 土默特左旗| 靖江市| 南投市| 焦作市| 旬阳县| 抚宁县| 夏邑县| 长宁区| 神农架林区| 离岛区| 凉城县| 云和县| 大名县| 兴城市| 遂溪县| 聂荣县| 苗栗县| 西和县| 鲁甸县| 湘乡市| 绥棱县| 东港市| 勃利县| 苏州市| 盐城市| 黄大仙区| 观塘区| 贺兰县| 南阳市| 梨树县| 三台县| 潞城市| 吴忠市| 金溪县| 巍山| 柳州市| 青龙|