Jump to content

Dropdown list using Field Type Page - Changing selection


NooseLadder
 Share

Recommended Posts

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

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

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>";
}
?>
  • Like 1
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...