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

  • concrete5 Cookbook
  • David Strack
  • 209字
  • 2021-08-13 16:15:55

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
主站蜘蛛池模板: 威信县| 兰溪市| 和平区| 浦江县| 柳林县| 临泽县| 揭阳市| 清流县| 盱眙县| 尉氏县| 南康市| 东乌珠穆沁旗| 什邡市| 新乡县| 周至县| 东兰县| 邮箱| 安龙县| 盖州市| 扎囊县| 昌乐县| 武邑县| 镇雄县| 德清县| 天柱县| 台东县| 鄂托克旗| 张家界市| 延边| 固安县| 富锦市| 贡觉县| 曲松县| 深泽县| 田东县| 迁安市| 姜堰市| 洛扎县| 仁化县| 洛阳市| 景德镇市|