Forum

Thread tagged as: Problem

perch_page_path variable not available

Issue report

The perch_page_path variable returns false if I try to to use PerchSystem::get_var, but not with PerchSystem::get_vars.

Andrés Fernández

Andrés Fernández 5 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you give an example?

Sure, I want to have a first level page marked as current in the main navigation menu for which I have the following:

<?php
$tmp = PerchSystem::get_vars(); // fix to make perch_page_path var available
$pageUri = preg_replace('/\/[a-z0-9]+(\.php)?$/', '/index.php', PerchSystem::get_var('perch_page_path'));

perch_layout('global.header', [
    'navCurrentPage' => $pageUri,
]); ?>
Drew McLellan

Drew McLellan 2638 points
Perch Support

I think you want

PerchSystem::get_page()

thanks