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

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
主站蜘蛛池模板: 和静县| 平和县| 宁波市| 彭阳县| 昭觉县| 南宫市| 东海县| 呼玛县| 永定县| 谢通门县| 西和县| 滦南县| 邯郸市| 类乌齐县| 高安市| 大连市| 石门县| 南漳县| 贵阳市| 应城市| 拉萨市| 张家港市| 隆子县| 贵定县| 吴堡县| 台中市| 洞头县| 辽源市| 崇义县| 柳河县| 波密县| 宁陵县| 汉川市| 安龙县| 古田县| 鄂尔多斯市| 宜阳县| 黎川县| 娄烦县| 苍山县| 日喀则市|