Skip to content

Add-on modules can't ship templates that resolveTemplate() finds #551

Open

Description

@caseysoftware

w2p_Theme_Base::resolveTemplate($template) only looks in style/<theme>/ and style/_common/. An add-on module can't put files there: it ships as one folder under modules/, and installing it shouldn't write into style/.

So add-ons can't follow the manual's advice for v5 ("Put your module's HTML in templates and include them with $AppUI->getTheme()->resolveTemplate('yourmodule/view')"). They either keep their markup inline in addedit.php / view.php (what Notebook does after its 5.0 port), or include their own files directly, and a theme can't override them either way.

Suggested fix
In resolveTemplate(), after style/<theme>/<template>.php and before style/_common/<template>.php, also try modules/<first path segment>/templates/<rest>.php. A template named notebook/view would then resolve to:

  1. style/bootstrap/notebook/view.php (a theme override)
  2. modules/notebook/templates/view.php (shipped with the module)
  3. style/_common/notebook/view.php

Core lookups are unchanged, because no core module has a templates/ folder. Mention the convention in the manual's "Updating Add On Modules for v5.0" section.

Found while porting the Notebook add-on to 5.0 (master 8727ad5c).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions