sambadave Posted April 27, 2015 Share Posted April 27, 2015 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 More sharing options...
LostKobrakai Posted April 27, 2015 Share Posted April 27, 2015 $puffColor = $article->$puff_color->title; // Needs to be $puffColor = $article->puff_color->title; Link to comment Share on other sites More sharing options...
sambadave Posted April 27, 2015 Author Share Posted April 27, 2015 You really are a lovely bunch of folks ProcessWire people. Thanks LostKobrakai, that worked perfectly. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now