- 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
推薦閱讀
- Monkey Game Development:Beginner's Guide
- JavaScript修煉之道
- Blockly創(chuàng)意趣味編程
- 微信公眾平臺開發(fā):從零基礎到ThinkPHP5高性能框架實踐
- 手把手教你學C語言
- C語言程序設計同步訓練與上機指導(第三版)
- Apache Spark 2.x for Java Developers
- Yii Project Blueprints
- Creating Mobile Apps with jQuery Mobile(Second Edition)
- Create React App 2 Quick Start Guide
- Python High Performance Programming
- AutoCAD 2009實訓指導
- Instant Debian:Build a Web Server
- OpenCV with Python Blueprints
- Python大規(guī)模機器學習