What Is The Difference Between $page->id(), uid() and uri()?

Just wondering whether there is an ‘official’ criteria for when to use each?

id() returns either the uid, or if the page has a parent, the parent’s id + the UID;

uid() returns the slug, i.e. in a multi-lang install the translated slug.

uri will return the translated id in multi-lang sites.

1 Like

So, for single-language sites, for some pages the id(), uid() and uri() will be the same, right?

First level pages, yes.

would be awesome to have these kind of infos in the docs…

4 Likes

I agree the descriptions like “Returns the ID” are sort of useless…

2 Likes

I agree, the docs could benefit from some further details here. Even the short description of uid() commented in the source code could be a welcome addition to the docs: https://github.com/getkirby/kirby/blob/3.4.3/src/Cms/Page.php#L1511

2 Likes