Page : get by name & get by handle

Permalink
Hi,

Is there a way to get page object by handle and by name ?
I only found : Page::getByPath() & Page::getByID()

Thanks

moosh
View Replies:
12345j replied on at Permalink Reply
12345j
$c->getCollectionHandle(); 
$c->getCollectionName();

check outhttp://www.weblicating.com/c5/cheat-sheet/... for future reference. you may have to define global c as well, if the above doesn't work.
moosh replied on at Permalink Reply
moosh
Thanks for your answer.

But I want get a page by handle or by name without known $c.

Example :
$page = Page::getByHandle('hello_page');
$page = Page::getByName('Hello page');
jordanlev replied on at Permalink Reply
jordanlev
Just noticed that -- edited my previous reply. Your first example works. Second one doesn't exist.
jordanlev replied on at Permalink Reply
jordanlev
EDIT: Oops, I misread the question. You can use Page::getByHandle() to get it by handle. But there is no method for getting it by name (probably because names aren't unique -- someone could name several pages the same so the code wouldn't know which one to retrieve).
moosh replied on at Permalink Reply
moosh
I can't find getByHandle() method...
Where is it ?
jordanlev replied on at Permalink Reply
jordanlev
uhh... you just type it into your code. Is it not working? If that's the case can you post the error message you're receiving?
moosh replied on at Permalink Reply
moosh
I have not try code.
I just would know where is the method:
/concrete/models/page.php => no method
jordanlev replied on at Permalink Reply
jordanlev
Oh, I get it!

It's in /concrete/models/collection.php

You will note that the Page class extends the Collection class, so it has all of the methods of the Collection class available to it as well. The terms "page" and "collection" are often used interchangeably throughout the code. There are slight technical differences between the two, but for the most part you can pretty much think of them as the same thing.
moosh replied on at Permalink Reply
moosh
Oh thanks!

Do you know the difference between Page & Collection ?

Thanks
jordanlev replied on at Permalink Reply
jordanlev
I don't quite understand the difference myself.