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

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
主站蜘蛛池模板: 沂源县| 新晃| 红安县| 民权县| 越西县| 中超| 阜新| 惠州市| 桃源县| 大方县| 化隆| 石狮市| 宜章县| 怀宁县| 广汉市| 江西省| 阜平县| 三台县| 高雄县| 永康市| 镇雄县| 托克托县| 宣汉县| 玛沁县| 安泽县| 尚志市| 治县。| 江门市| 周宁县| 长岭县| 崇阳县| 满城县| 玉龙| 唐山市| 金昌市| 永胜县| 中江县| 阳谷县| 越西县| 沂源县| 花莲市|