C5.7 Getting page attribute in template
Permalink
Hi! I have added a page attribute "slideshow" to C5. This attribute is now included (checked) in all my pages where a slideshow should show up at the top of the page. I´m calling this slideshow from javascript so I need to identify on which page the attribute "slideshow" is checked or not.
I´m thinking about giving the body a class with "slideshowTrue" or "slideshowFalse" and call the slideshow with js depending on this class.
But how is it possible (5.7) to get the value of this page attribute to append its value to the body?
Cheers
I´m thinking about giving the body a class with "slideshowTrue" or "slideshowFalse" and call the slideshow with js depending on this class.
But how is it possible (5.7) to get the value of this page attribute to append its value to the body?
Cheers
That´s the code I´m using now. Thanks!
Where $value is now 0 or 1
$page = \Page::getCurrentPage(); $value = $page->getAttribute('slideshow');
Where $value is now 0 or 1
You can just use $c.
"Retrieving the Current Page Object
From within a Page Template
Within a page template (e.g. a template file found in a theme or a single page template) you don't have to do anything to retrieve the current page object. It's already present in the local scope:
$c
(The $c stands for "current page.")"
http://www.concrete5.org/documentation/developers/5.7/working-with-...
"Retrieving the Current Page Object
From within a Page Template
Within a page template (e.g. a template file found in a theme or a single page template) you don't have to do anything to retrieve the current page object. It's already present in the local scope:
$c
(The $c stands for "current page.")"
http://www.concrete5.org/documentation/developers/5.7/working-with-...
Here is something you can try.