Skip to content

Feature Request: Native subdirectory support for template files and improved "Alternate Template Filename" handling #575

@mxmsmnv

Description

@mxmsmnv

As a project grows, the /site/templates/ directory becomes cluttered with dozens of PHP files (SSO handlers, AJAX controllers, admin-only views, etc.). Currently, organizing these into subfolders (e.g., /site/templates/sso/login.php) requires manually setting the "Alternate Template Filename" for each template.

However, the current implementation is restrictive:

  1. The field often strips the path or resets if the file doesn't exist at the exact moment of saving.
  2. There is no visual way to see or manage the folder structure within the Setup -> Templates list.
  3. Developers have to repeat the same path-entry process for every single file in a group.

Describe the solution you'd like
I would like to see "First-class citizen" support for subdirectories in the templates folder:

  1. Path persistence: Ensure the "Alternate Template Filename" field reliably accepts and saves relative paths like folder/filename.php without aggressive validation that might strip the directory prefix.
  2. Template Groups/Folders in Admin: The ability to group templates in the Admin UI (Setup -> Templates) based on their physical folder location.
  3. Automatic discovery: An option to tell ProcessWire to look for a template file in a subdirectory by default if it's not found in the root (e.g., if a template is named sso-login, PW could check for /sso/login.php automatically).

Describe alternatives you've considered
Currently, we use include or wireRenderFile inside a "bridge" file in the root, but this adds unnecessary file overhead and creates even more files in the root directory.

Additional context

Image

As seen in the attached screenshot, managing 40+ files in a single flat list makes the development process prone to errors and hard to navigate.

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