Forum

Thread tagged as: Problem, Error, Api

Passing Page Attribute into php variable

Hi Guys,

my second question this day, sorry for that.

I need to pass a page attribute into a php-variable, like:

$currentpage = perch_page_attribute('id');

Problem is, that the value is not written into the variable but straight to the html.

i found this searching the forum, whit works fine for the page title but not for a custom attribute:

$currentpage = perch_pages_attribute('id', array('raw' => 'true'), true);

Can anybody help me, please? (i'm very new into php, just now very basic stuff!)

Best Manuel

Manuel Hügel

Manuel Hügel 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

That would be correct:

$currentpage = perch_page_attribute('id', [], true);

Can you show us the code that isn't working?

The not working code was exact this:

    $currentpage = perch_pages_attribute('keywords', array('raw' => 'true'), true);
    echo $currentpage;

Result was this:

Fatal error: Call to undefined function perch_pages_attribute() in C:\xampp\htdocs\ksc\perch\templates\pages\ksc_berichte.php on line 14

But your code worked just fine. Thanks for that!