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

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
主站蜘蛛池模板: 隆安县| 台前县| 徐水县| 宜黄县| 汪清县| 辽中县| 句容市| 涞源县| 米脂县| 吉安市| 吐鲁番市| 桐柏县| 高清| 东至县| 宜良县| 铜川市| 永寿县| 呼图壁县| 扶余县| 黄龙县| 鹿泉市| 汽车| 喀喇沁旗| 商城县| 疏附县| 新建县| 枣阳市| 进贤县| 达孜县| 万州区| 拉孜县| 怀远县| 达拉特旗| 罗定市| 定日县| 兴海县| 于田县| 海晏县| 九龙城区| 凉城县| 乐都县|