Forum

Thread tagged as: Problem

Use Perch_layout_var in If statement

Hi Guys.

Is it possible to do something like this?

if (perch_layout_var('text') == 'X') {
   show something
} else {
   show something else
}

I have some small alterations to my nav between pages and I don't want to have to use 2 different nav includes.

Cheers

Chris Bell

Chris Bell 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Sure:

if (perch_layout_var('text', true) == 'X') {
   show something
} else {
   show something else
}

With Perch functions, passing true as the final argument causes the value to be returned rather than echoed.

Cool thanks