官术网_书友最值得收藏!

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:

  1. Open /config/site_post.php in your code editor.
  2. Load the Page object by its path.
    $page = Page::getByPath('/about');
  3. Get the page's ID.
    $id = $page->getCollectionId();
  4. 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
主站蜘蛛池模板: 七台河市| 肥城市| 梁平县| 进贤县| 开封市| 沂南县| 石林| 安图县| 安龙县| 冕宁县| 宜阳县| 苍梧县| 鹤岗市| 盐山县| 精河县| 邹城市| 博湖县| 庆云县| 株洲市| 岢岚县| 贵溪市| 惠州市| 张家界市| 临泉县| 宁乡县| 阳东县| 潜山县| 尚志市| 新余市| 浦江县| 洮南市| 凌海市| 朝阳区| 宜宾县| 平江县| 海南省| 扶绥县| 六安市| 开阳县| 天门市| 丽水市|