- 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
推薦閱讀
- Ext JS Data-driven Application Design
- C/C++算法從菜鳥到達人
- Django Design Patterns and Best Practices
- Java 11 Cookbook
- Hands-On Full Stack Development with Go
- Linux C編程:一站式學習
- C語言程序設計
- Cocos2d-x Game Development Blueprints
- Mastering AWS Security
- 零基礎學Scratch 3.0編程
- Application Development with Swift
- C#面向對象程序設計(第2版)
- Clojure High Performance Programming(Second Edition)
- 從零開始學UI:概念解析、實戰提高、突破規則
- Java EE互聯網輕量級框架整合開發:SSM+Redis+Spring微服務(上下冊)