This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Droach5875216
Can anyone advise a good way to access a function of the Page class from within the PHP code section of a CMS page? Can this be done?
ndcisiv
Not sure what function of the Page class you are looking to call, but the idea is simple. In you page code section just simply do:
<?
function onStart()
{
echo $this->page->getObjectTypeDirName();
}
?>
Droach5875216
Gotcha. I worked it out on my own, found a simpler way: Assuming getWorkMenus is a function in my page class. use Cms\Classes\Theme; use Cms\Classes\Page;
function onStart(){
$pages = Page::getWorkMenus();
foreach($pages as $page){
error_log(print_r($page->url,1));
}
}
1-3 of 3