page alias

Permalink
Hello,

I have a very simple question I cannot seem to find the answer to.

How can I access the page alias of an existing page in concrete 5? For instance, with this url:

http://halftohelp-v3.avidanodev.com/artists/amy-albers/...

I would like to use "amy-albers" as a variable.

I am not sure how to retrieve this data.

Any help is appreciated.

Thanks,
Carl

cavidano1
 
olliephillips replied on at Permalink Best Answer Reply
olliephillips
You don't say how you want to use it, whether in the currently loaded page on itself, or returning all pages.

If within the current page, this will return an object for the current page, and let you access the handle:-

$page = Page::getCurrentPage();
$pageHandle = $page->getCollectionHandle();
echo $pageHandle;


If you want to operate on all pages then you'd do something like this:-

Loader::model('page_list');
$pl = new PageList();
## Set filters here
$pages = $pl->get();
foreach ($pages as $page){
  $pageHandle = $page->getCollectionHandle();
  echo $pageHandle;
}


Hope that helps
cavidano1 replied on at Permalink Reply
cavidano1
Thanks Ollie. That is perfect.

Sorry for the late response.

I am using it as a PHP variable to populate jQuery lightboxes on the artist pages.

Thanks again for your response.

Best,
Carl