- concrete5 Cookbook
- David Strack
- 137字
- 2021-08-13 16:15:57
Getting a page's ID
Developers will often need to know a page's ID, especially when relating pages to other database objects (such as a blog post or calendar event). In this example, we will load the /about
page that we've been working with and get its ID.
Getting ready
Please make sure the /about
page exists in your instance of concrete5. Feel free to modify the code in this recipe if that page does not exist.
How to do it...
The steps for getting a page's ID are as follows:
- Open
/config/site_post.php
in your code editor. - Load the
Page
object by its path.$page = Page::getByPath('/about');
- Get the page's ID.
$id = $page->getCollectionId();
- Dump the contents of the
$id
variable to see what the ID is.my_debug($id);
See also
- The Getting a page by its path recipe
推薦閱讀
- 密碼學原理與Java實現
- Java 9 Concurrency Cookbook(Second Edition)
- 少年輕松趣編程:用Scratch創作自己的小游戲
- JavaFX Essentials
- Learning ArcGIS Pro
- Microsoft Azure Storage Essentials
- jQuery炫酷應用實例集錦
- 測試架構師修煉之道:從測試工程師到測試架構師
- Python Machine Learning Cookbook
- Learning Kotlin by building Android Applications
- Java高級程序設計
- Node.js應用開發
- INSTANT Lift Web Applications How-to
- 數據庫技術及應用教程上機指導與習題(第2版)
- Android Application Programming with OpenCV 3