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

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
主站蜘蛛池模板: 霞浦县| 越西县| 博罗县| 陵川县| 商水县| 临夏市| 晋州市| 南和县| 朔州市| 尼木县| 托克逊县| 洛隆县| 北碚区| 屏南县| 峨山| 丹巴县| 兴山县| 宁海县| 白沙| 普格县| 金坛市| 内江市| 五寨县| 礼泉县| 宁强县| 吉安县| 五家渠市| 郯城县| 宁城县| 阳山县| 景宁| 进贤县| 赫章县| 迁安市| 梅河口市| 绍兴市| 京山县| 荥阳市| 南充市| 新巴尔虎右旗| 天水市|