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
Is there a way to get page object by handle and by name ?
I only found : Page::getByPath() & Page::getByID()
Thanks
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');
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');
Just noticed that -- edited my previous reply. Your first example works. Second one doesn't exist.
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).
I can't find getByHandle() method...
Where is it ?
Where is it ?
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?
I have not try code.
I just would know where is the method:
/concrete/models/page.php => no method
I just would know where is the method:
/concrete/models/page.php => no method
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.
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.
Oh thanks!
Do you know the difference between Page & Collection ?
Thanks
Do you know the difference between Page & Collection ?
Thanks
I don't quite understand the difference myself.
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.