Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Posibillity to override Widget Templates with own templates #123

Closed
ludwigmair opened this issue Mar 19, 2020 · 5 comments
Closed

Posibillity to override Widget Templates with own templates #123

ludwigmair opened this issue Mar 19, 2020 · 5 comments

Comments

@ludwigmair
Copy link

ludwigmair commented Mar 19, 2020

Hi,
i receantly tryed to override Widget Templates with my own from a other extension.
therefor i discovered that the call for a template is sort of set in stone.

"setTemplate('Widget/"
and "fillDefaultsByPackageName('dashboard')"

protected function initializeView(): void
    {
        $this->view = GeneralUtility::makeInstance(StandaloneView::class);
        $this->view->setTemplate('Widget/' . $this->templateName);

        $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat'] ? '%m-%d-%Y' : '%d-%m-%Y';
        $this->view->assign('dateFormat', $dateFormat);

        $this->view->getRenderingContext()->getTemplatePaths()->fillDefaultsByPackageName('dashboard');

        $this->view->assign('title', $this->getTitle());
    }

please provide a solution how to make it possible to override a given template with a custom template.

thanks

best regards Ludwig

@kaystrobach
Copy link
Contributor

Please provide a use case for this.

@DanielSiepmann
Copy link
Contributor

DanielSiepmann commented Mar 19, 2020

It is possible, you can configure like any other module or plugin:

module.tx_dashboard {
    view {
        templateRootPaths {
            100 = EXT:own_extension/Resources/Private/Templates/Dashboard/
        }
    }
}

A use case might be to implement custom Widgets with their own Template.
A Documentation is in the making which will also contain this information.

Please note that 0 - 100 are used for TYPO3 system extensions. So please use a higher value.

@NamelessCoder
Copy link
Contributor

As @DanielSiepmann already mentioned: you can add paths to the EXT:dashboard set of paths, then they will be read by fillDefaultsFromPackageName. Which means you can both override existing templates and add new ones.

@ludwigmair
Copy link
Author

Hi,

thanks for all the responses, i really appreciate it.
i definately will try all your recommendations to figure out what works best for me

cheers Ludwig

@ludwigmair
Copy link
Author

Hi,
many thanks for all your help. It works. Fantastic

cheers Ludwig

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants