- 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:
- Open
/config/site_post.php
in your code editor. - Load the page type by its path:
$pageType = CollectionType::getByHandle('right_sidebar');
- Get the ID from the page type.
$id = $pageType->getCollectionTypeId();
- 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
推薦閱讀
- Java EE框架整合開發入門到實戰:Spring+Spring MVC+MyBatis(微課版)
- C和C++安全編碼(原書第2版)
- Vue.js 3.0源碼解析(微課視頻版)
- Mastering matplotlib
- 人臉識別原理及算法:動態人臉識別系統研究
- YARN Essentials
- PostgreSQL 11從入門到精通(視頻教學版)
- Learning ELK Stack
- MongoDB權威指南(第3版)
- HTML5+CSS3網頁設計
- 可解釋機器學習:模型、方法與實踐
- Unity Game Development Scripting
- MATLAB 2020從入門到精通
- 從零開始學Linux編程
- 用戶體驗可視化指南