templatePath in Plugin

Hey guys!

Is there a way to define a templatePath in a plugin (external package)?

My Site ist My.Site and the external package named Fundamental.Package

This is the fusion in the My.Site Package:

prototype(Fundamental.Package:NewsMenu) {
  templatePath = 'resource://My.Site/Private/Templates/News/Index.html'
}

and this is the fusion in the Fundamental.Package

prototype(Fundamental.Package:NewsMenu) < prototype(Neos.Neos:Plugin)
prototype(Fundamental.Package:NewsMenu) {
    package = 'Fundamental.Package'
    controller = 'News'
    action = 'index'
    newsarticles = ${q(node).property('newsarticles')}
    nodeident = ${q(node).property('nodeident')}
    pagebrowser = ${q(node).property('pagebrowser')}
    showDate = ${q(node).property('showDate')}
    sorting = ${q(node).property('sorting')}
    attributes = ${q(node).property('addClass')}
    @cache {
        mode = 'uncached'
        context {
            1 = 'node'
            2 = 'documentNode'
        }
    }
}

Thx, pat

Not sure I understand the actual question. The code you proposed should work just fine as long as My.Site depends on Fundamental.Package in it’s composer.json and that Fusion is included/loaded for both packages.

Hi Aske!

Thank you for your answer.
Hm, I think in Neos.Neos:Plugin the variable templatePath is not respected. Is that possible?

The template of the Fundamental.Package is always loaded and not my new/own template.

Thx,
pat

Ah right, sorry definitely misunderstood your question.

To overwrite a template for a Plugin (which is based on a controller request) you need to use Views.yaml configuration. See http://flowframework.readthedocs.io/en/stable/TheDefinitiveGuide/PartIII/ModelViewController.html#configuring-views-through-views-yaml

Doing it based on the Fusion object wouldn’t be easy to do, so would not recommend it.

Thank you Aske! It works with:

-
  requestFilter: 'isPackage("Fundamental.Package") && isController("News") && isAction("index")'
  options:
    templatePathAndFilename: 'resource://My.Site/Private/Templates/News/Index.html'