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

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
主站蜘蛛池模板: 儋州市| 东莞市| 海宁市| 金溪县| 同仁县| 乌拉特中旗| 葵青区| 红河县| 清水县| 威海市| 台江县| 白河县| 靖宇县| 南澳县| 康马县| 华池县| 专栏| 抚宁县| 绍兴县| 上栗县| 临湘市| 耒阳市| 汨罗市| 灵璧县| 二连浩特市| 伊春市| 轮台县| 马尔康县| 花莲县| 彩票| 定西市| 屏山县| 长岭县| 合作市| 光山县| 中阳县| 小金县| 含山县| 安宁市| 福州市| 吴堡县|