Skip to content

Determine default template behavior for locator page #253

@jsirish

Description

@jsirish

Summary

The locator module has two database fields that control default visibility behavior, but they require manual CMS configuration and the default values may not provide the expected user experience.

Current Behavior

Field Database Type Default Value Purpose
ShowResultsDefault Boolean false (assumed) Show locations on initial page load
ShowFormDefault Boolean true (assumed) Show the search form on initial page load

Controller Logic:

  • LocationSearch() returns null if ShowFormDefault is false, hiding the form
  • index() returns empty ArrayList if ShowResultsDefault is false, showing no locations

User Experience Issue

When a user visits /locator for the first time:

  1. Form is hidden (unless ShowFormDefault = true in CMS)
  2. No locations shown (unless ShowResultsDefault = true in CMS)
  3. User sees empty page with no guidance

This requires administrators to manually configure these settings in the CMS for basic functionality.

Current Implementation

// Locator.php - Database fields
private static $db = [
    'Unit' => 'Enum("m,km","m")',
    'ShowResultsDefault' => 'Boolean',
    'ShowFormDefault' => 'Boolean',
];

// LocatorController.php
public function LocationSearch(): ?LocatorForm
{
    if (!$this->ShowFormDefault) {
        return null;  // Form hidden
    }
    // ...
}

public function index(HTTPRequest $request)
{
    if ($this->getTrigger($request) || $this->ShowResultsDefault) {
        $locations = $this->getLocations();
    } else {
        $locations = ArrayList::create();  // Empty
    }
    // ...
}

Recommended Approach

Option A: Show form by default, hide results

  • ShowFormDefault = true (show search form)
  • ShowResultsDefault = false (don't show results until search)
  • User sees search form with no results initially

Option B: Show form AND results by default

  • ShowFormDefault = true
  • ShowResultsDefault = true
  • User sees search form and all locations on initial load

Option C: Remove these fields entirely

  • Always show form
  • Always show all locations (or add a setting)
  • Simplifies the module configuration

Recommendation

Option A seems most appropriate for most use cases:

  • Users see the search form immediately
  • Results are only shown after aents showing empty state search (prev)
  • Maintains the search-first paradigm

However, some use cases (like a directory) might want Option B.

Next Steps

  1. Decide on the default behavior
  2. Set appropriate defaults in Locator::$defaults
  3. Update controller logic if needed
  4. Update documentation

Labels: enhancement, user-experience, help-wanted

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions