- concrete5 Cookbook
- David Strack
- 179字
- 2021-08-13 16:15:55
Getting a page type's handle
If a page type has been loaded by its ID or has been provided in a different manner, developers may want to retrieve the handle of the page type. In this example, we will load a page type with an ID of 4
and use the concrete5 API to get its handle.
Getting ready
We will be loading a page type with an ID of 4, so please ensure that this exists in your concrete5 website. Feel free to change the ID in this recipe to something appropriate for your instance of concrete5.
How to do it...
The steps for getting a page type's handle are as follows:
- Open
/config/site_post.php
in your preferred code editor. - Load the page type by its ID.
$pageType = CollectionType::getByID(4);
- Get the handle of the page type.
$handle = $pageType->getCollectionTypeHandle();
- Dump the handle using our custom debugger function.
my_debug($handle);
How it works...
The function getCollectionTypeHandle
of the page type object returns the handle string of the page type.
See also
- The Getting a page type by its ID recipe