- 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
推薦閱讀
- Advanced Machine Learning with Python
- 小創客玩轉圖形化編程
- Mastering SVG
- Learning C++ Functional Programming
- Flask Web開發入門、進階與實戰
- Python應用輕松入門
- Android Native Development Kit Cookbook
- Drupal 8 Module Development
- 學習正則表達式
- Java:High-Performance Apps with Java 9
- C++從入門到精通(第5版)
- Red Hat Enterprise Linux Troubleshooting Guide
- 編程可以很簡單
- 深入解析Java編譯器:源碼剖析與實例詳解
- 微前端設計與實現