- concrete5 Cookbook
- David Strack
- 152字
- 2021-08-13 16:15:55
Getting a page type's name
Page type objects also contain methods to retrieve the name of the page type. In this exercise, we will load a page type by its handle, and then retrieve the name of the page type.
Getting ready
We will be loading a page type with the handle of right_sidebar
, so if that page type does not exist in your instance of concrete5, please adapt this recipe to suit your needs.
How to do it...
The steps for getting a page type's name are as follows:
- Open
/config/site_post.php
in your preferred code editor. - Load the page type by its handle:
$pageType = CollectionType::getByHandle('right_sidebar');
- Get the name of the page type.
$name = $pageType->getCollectionTypeName();
- Dump the name using our custom debugger.
my_debug($name);
How it works...
The getCollectionTypeName
function simply returns the string value of the page type's name.
See also
- The Getting a page type by its handle recipe