bithost-gmbh / pdfviewhelpers

TYPO3 CMS extension that provides various Fluid ViewHelpers to generate PDF documents.
GNU General Public License v3.0
44 stars 20 forks source link

[Feature] use multiple fluid templates for different EXT:news pdfs #114

Closed medarob closed 5 years ago

medarob commented 5 years ago

Hi,

not really an issue but maybe feature, if not already possible: I have the news extensions installed and using it for normal news and also job descriptions. And maybe there are other use cases for the news extensions... Now I want the news pdfs look different than the job pdfs.

Is that possible somehow? Do I have to use different page types for different news pdfs?

Thank you

maechler commented 5 years ago

Using a separate page type for each PDF could be one solution. But then you need to make sure that you also include the setup from Configuration/TypoScript/Extensions/News/setup.txt for that page type.

Another way could probably be to add a GET parameter pdf_type=2 and then use a TypoScript condition to set the template path:

[globalVar = GP:pdf_type = 2]
    plugin.tx_news {
        view {
            templateRootPaths >
            templateRootPaths {
                0 = EXT:pdfviewhelpers/Resources/Private/Templates/Extensions/News/TemplatesV2/
            }
        }
    }
[global]

Or you could even do it in the Fluid template:

<f:switch expression="{news.type}">
    <f:case value="job">
               <f:render partial="News/Job" arguments="{news: news}" />
        </f:case>
    <f:case value="news">
               <f:render partial="News/News" arguments="{news: news}" />
        </f:case>
</f:switch>

But then you also need to add the path to your partials to partialRootPaths:

plugin.tx_news {
        view {
                partialRootPaths >
                partialRootPaths {
                        0 = EXT:news/Resources/Private/Partials/
                        1 = fileadmin/templates/ext/news/Partials/
                }
        }
}

Each partial would then contain a separate PDF document. I would probably go for the Fluid version.

medarob commented 5 years ago

Thank you, I will try this approach :)