Thread tagged as: Question, Problem

Header layout value from master pages


I am creating a website which consists of three parts:




All pages and subpages are created from masterpages, because the pages are the same but the content is different. I have created css files to change color, so all three pages have to have different css files:

mydomain.test/zonnepanelen/ - green.css

mydomain.test/led-verlichting/ - blue.css

mydomain.test/infraroodverwarming/ - yellow.css

I have one header layout for all pages.

Now in my header.php layout I have tried the following conditional:

        if (perch_layout_has('green')) {
            echo '<link href="/css/green.css" rel="stylesheet">';
        } else if (perch_layout_has('blue')) {
            echo '<link href="/css/blue.css" rel="stylesheet">';
        } else {
            echo '<link href="/css/yellow.css" rel="stylesheet">';

and in my masterpage:

    perch_layout('header', array(
        "blue" => true

So, how can I pass the layout value to those pages when they are all coming from the same master page? I hope this explanation makes sense.


Mike Hendriks

Mike Hendriks 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

I would use page attributes for that.

Great solution! It is working now, thank you Drew.