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

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
主站蜘蛛池模板: 乌鲁木齐市| 蛟河市| 图木舒克市| 奎屯市| 姚安县| 蕲春县| 乌兰浩特市| 北辰区| 潼南县| 应用必备| 仙游县| 双峰县| 江门市| 隆回县| 洛宁县| 绥化市| 定州市| 天长市| 哈尔滨市| 万全县| 苍溪县| 琼海市| 兴安县| 重庆市| 财经| 赣榆县| 凉城县| 彩票| 新龙县| 吉木乃县| 昌图县| 东港市| 迁西县| 梨树县| 辽中县| 曲麻莱县| 泸水县| 定南县| 淮安市| 黔江区| 万荣县|