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

  • 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:

  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
主站蜘蛛池模板: 新津县| 华安县| 镇巴县| 青岛市| 和平县| 平乐县| 灵武市| 水富县| 页游| 乌兰县| 基隆市| 原平市| 江城| 甘肃省| 太康县| 井冈山市| 霞浦县| 清涧县| 临沧市| 安国市| 当涂县| 聂荣县| 全州县| 会昌县| 略阳县| 嘉鱼县| 塘沽区| 胶南市| 屏山县| 龙岩市| 当阳市| 鹤庆县| 沭阳县| 北辰区| 龙海市| 楚雄市| 隆德县| 双江| 玛多县| 辽宁省| 丹寨县|