Jump to content

pull value from page field


sambadave
 Share

Recommended Posts

Hi folks

I have a parent page which contains a list of sub pages links. Each sub page link has a title and a picture. I'm also trying to make the background colour selectable from a range of options, using a page field.

All the sub pages contain a page field called $puff_color. This page field is set up as a select box and pulls values from pages with title only, such as yellow, blue, gray, black etc.

I'm trying to create a simple loop through all the child pages, whilst pulling these colours into the markup as a css class. I can't figure out why $puffColor doesn't show anything.

I'm not great with php so any help or advice would be appreciated.

Thanks

<?php

            foreach($page->children as $article) {

            $puffColor = $article->$puff_color->title;

            echo "<section class='box-puff {$puffColor}'>
                <div>...other content...</div>
            </section>";

            }
            ?>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...