NooseLadder Posted December 6, 2012 Share Posted December 6, 2012 I have set up a dropdown list for backend use: Created pages: Categories (template called categories) - category1 (template called category_item) - category2 - category3 Created field called category with page type = page and Input > Parent of selectable pages = Categories and Input > Template of selectable pages = category_item and Input field type = Select. I create a template including the field category, and create a page using this template and select the required option (category1) from the dropdown and save. If I go back and change the option to a different one (category2) from the original and save I find that both options are now assigned to that page (category1 | category2). If I change this to Field Type = AsmSelect I can see the two options listed in the page content area and can now delete the one not required. Is that how filed type = Select is supposed to work? Link to comment Share on other sites More sharing options...
ryan Posted December 6, 2012 Share Posted December 6, 2012 On your 'details' tab of the field, check to make sure that your field is a "Single Page" and not a "Multiple Page" field. Link to comment Share on other sites More sharing options...
NooseLadder Posted December 7, 2012 Author Share Posted December 7, 2012 It was set as multiple so I changed it to single page and what happens is that the category title (see comment in code below) is no longer displayed on the page view. I have 4 category pages (category1, category2, category3, category4) and the code below is displaying 13 duplicates from each page. Maybe it's my code on the page view. <?php foreach($page->children("template=category_item, sort=date") as $event) { foreach($event->categories as $category) { echo "<div class='event_listing'> <h2>{$event->title}</h2> <p><strong>Group:</strong> {$category->title}</p> //this is not displayed with the field set to Select and single page <p><strong>Starting:</strong> {$event->date}</p> <p><strong>Description:</strong> {$event->description}</p> <p><strong>Contact Name:</strong> {$event->contact_name}</p> <p><strong>Telephone:</strong> {$event->telephone}</p> <p><strong>Email:</strong> {$event->email_address}</p> </div>"; }} ?> Link to comment Share on other sites More sharing options...
NooseLadder Posted December 7, 2012 Author Share Posted December 7, 2012 I think I have solved this. I have changed the code to: <?php foreach($page->children("template=category_item, sort=date") as $event) { echo "<div class='event_listing'> <h2>{$event->title}</h2> <p><strong>Group:</strong> {$event->category->title}</p> //this line changed and second foreach removed <p><strong>Starting:</strong> {$event->date}</p> <p><strong>Description:</strong> {$event->description}</p> <p><strong>Contact Name:</strong> {$event->contact_name}</p> <p><strong>Telephone:</strong> {$event->telephone}</p> <p><strong>Email:</strong> {$event->email_address}</p> </div>"; } ?> 1 Link to comment Share on other sites More sharing options...
ryan Posted December 7, 2012 Share Posted December 7, 2012 Looks like you got it. The reason the first one didn't work is because $event->categories was a Page rather than a PageArray. So you were cycling the pages fields rather than categories. Link to comment Share on other sites More sharing options...
NooseLadder Posted December 8, 2012 Author Share Posted December 8, 2012 Thanks for your help. 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