- 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
推薦閱讀
- Puppet 4 Essentials(Second Edition)
- Delphi程序設計基礎:教程、實驗、習題
- 軟件界面交互設計基礎
- Java:Data Science Made Easy
- 零基礎學Python數據分析(升級版)
- SQL Server 2016數據庫應用與開發習題解答與上機指導
- Domain-Driven Design in PHP
- JavaScript腳本特效編程給力起飛
- Mastering Docker
- Python從入門到精通(第3版)
- SpringBoot從零開始學(視頻教學版)
- Java 9 with JShell
- HTML5+CSS3+JavaScript案例實戰
- Testing Practitioner Handbook
- SFML Essentials