- 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
推薦閱讀
- Vue.js 3.x快速入門
- iOS Game Programming Cookbook
- JavaScript前端開發模塊化教程
- Drupal 8 Blueprints
- Learning Neo4j 3.x(Second Edition)
- QTP自動化測試進階
- MongoDB權威指南(第3版)
- Clojure Reactive Programming
- 從零開始學C語言
- Julia高性能科學計算(第2版)
- RESTful Web API Design with Node.js(Second Edition)
- 美麗洞察力:從化妝品行業看顧客需求洞察
- WCF編程(第2版)
- Access 2016數據庫應用與開發:實戰從入門到精通(視頻教學版)
- INSTANT Apache Maven Starter