Get Current Page Name3 users found helpful
I've been looking through the readily available information on themes and also looking at the code in the default themes but I don't see this anywhere. Anyone have a clue how to do it?
<?php $page = Page::getCurrentPage(); echo $page->getCollectionName(); ?>
The code that I got to work is:
This works fine when outside of the Area object ($a). I am trying to fetch the stored value of an area object before displaying it. ie. NOT $a->display($c)
This post helped me find that. Thanks :)
Not sure it didn't work, but if anybody has any problems with the first method post here and I'll assist.
Second issue of using a variable is that it might be overwritten (using something as ubiquitous as a letter `c` for a (pseudo) global variable is already giving me the creeps), but a method will never be overwritten in PHP.
Therefore, technically it's perfectly safe to access $c in a template file. You can even use it in a controller if you precede it with "global $c" but I guess that's getting on thinner ice.
Also accessing the data via attributes rather than properties is more prone to unexpected behavior when accessing this sort of a global variable, somewhat bad design on the point of view of system architecture. But well, Concrete5 is written with PHP and ergo one should expect that it comes with its luggage.