Project

General

Profile

Actions

Bug #60338

closed

Changing view format does not affect partial format

Added by Mathias Brodala over 10 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Must have
Assignee:
Category:
-
Target version:
Start date:
2014-07-15
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:
Remote Sprint

Description

When using one view object to render a template in different formats (e.g. email in text and HTML), the template respects the requested format. However, partials are always rendered in the first rendered format. Example:

Content of templates/partials:

Content of Foo.txt:

Hello
<f:render partial="Bar"/>

Content of Partials/Bar.txt:

World

Content of Foo.html:

<p>Text</p>
<f:render partial="Bar"/>

Content of Partials/Bar.html:

<p>World</p>

1st invocation:

// Let $view be an instance of \TYPO3\CMS\Fluid\View\TemplateView
$view->setFormat('txt');
$view->render('Foo');

Result:

Hello
World

2nd invocation:

// $view is the same instance as above
$view->setFormat('html');
$view->render('Foo');

Result:

<p>Hello</p>
World

As you can see, the 2nd output was rendered using the txt-Partial.

This is due to the local partial identifier cache in AbstractTemplateView which only considers the partial name, not the current request format. If that one is incorporated, separate cache entries for each partial formats are created.


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Feature #66111: Add TemplateRootPaths support to cObject FLUIDTEMPLATEClosed2015-03-28

Actions
Actions #1

Updated by Mathias Brodala over 10 years ago

The setFormat call is not possible with the default TemplateView of course. Imagine one would modify the current Request object instead which also resides in the ControllerContext.

Actions #2

Updated by Markus Klein over 10 years ago

  • Project changed from 2559 to TYPO3 Core
  • Category deleted (Fluid: View)
  • Status changed from New to Accepted
Actions #3

Updated by Markus Klein over 10 years ago

  • TYPO3 Version set to 6.2
  • Is Regression set to No

Please report all Bugs to the Core project. Fluid and Extbase projects are legacy only.

Actions #4

Updated by Gerrit Code Review almost 10 years ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/35475

Actions #5

Updated by Markus Klein over 9 years ago

We use it with StandaloneView like this and have no problems:

        $view->setTemplateSource(self::getTemplate($templatePath . '.html', $languagePath));
        $view->setFormat('html');
        $mailContent['html'] = $view->render();

        $view->setTemplateSource(self::getTemplate($templatePath . '.txt', $languagePath));
        $view->setFormat('txt');
        $mailContent['text'] = $view->render();

Can you figure out the difference to TemplateView here?

Actions #6

Updated by Mathias Brodala over 9 years ago

Markus Klein wrote:

We use it with StandaloneView like this and have no problems:
[...]

Does your template reference a partial which exists in txt and html format? Is that partial properly rendered depending on format?

Actions #7

Updated by Markus Klein over 9 years ago

Yes we reference a partial called "footer" in the mails which is present in .html and .txt format.
The output is correct.

Actions #8

Updated by Mathias Brodala over 9 years ago

The thing is that StandaloneView does not support templateRootPaths which we need to provide a default template with a list of optional overrides. That's why we cannot switch from TemplateView.

Actions #9

Updated by Markus Klein over 9 years ago

StandaloneView will get templateRootPaths ;-) that has just been discussed.

But this actually does not matter here. The question is, why does this fail with TemplateView but work with StandaloneView?
Or is it something else that makes up the difference.

Actions #10

Updated by Mathias Brodala over 9 years ago

Markus Klein wrote:

StandaloneView will get templateRootPaths ;-) that has just been discussed.

AFAIS this is about the FLUIDTEMPLATE content object, not the StandaloneView: #66111

But this actually does not matter here. The question is, why does this fail with TemplateView but work with StandaloneView?
Or is it something else that makes up the difference.

Well, a huge difference is in createIdentifierForFile but it's a bit hard to track down.

Actions #11

Updated by Markus Klein over 9 years ago

We discussed that and concluded that it has to go into StandaloneView and FLUIDTEMPLATE will use it.

Actions #12

Updated by Mathias Brodala over 9 years ago

Markus Klein wrote:

We discussed that and concluded that it has to go into StandaloneView and FLUIDTEMPLATE will use it.

Sounds great and would at least solve my issue at hand if I switch to StandaloneView then.

Is this still tracked in the ticket I've linked or another one?

Actions #13

Updated by Markus Klein over 9 years ago

I'm not aware of another ticket.

Actions #14

Updated by Markus Klein over 9 years ago

But it is no solution to switch everything to StandaloneView. Formats have to work for partials, no question!

So it would really be cool good to find out the difference.

Actions #15

Updated by Markus Klein over 9 years ago

Ah one more note: I only tested this on master, since my extension is CMS 7 only, no 6.2 support. So maybe the issue is only in 6.2

Actions #16

Updated by Mathias Brodala over 9 years ago

Markus Klein wrote:

But it is no solution to switch everything to StandaloneView. Formats have to work for partials, no question!

So it would really be cool good to find out the difference.

Yes of course. I just wanted to add the proper issue relation. ;-)

Actions #17

Updated by Gerrit Code Review over 9 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/35475

Actions #18

Updated by Markus Klein over 9 years ago

  • Assignee set to Markus Klein
  • Sprint Focus set to Remote Sprint
Actions #19

Updated by Markus Klein over 9 years ago

I can confirm the issue with StandaloneView as well!

A simple workaround though is to define the format explicitly in the txt-template.

Example

Foo.html

<f:render partial="Footer" />

Foo.txt

<f:render partial="Footer.txt" />

Actions #20

Updated by Gerrit Code Review over 9 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/35475

Actions #21

Updated by Gerrit Code Review over 9 years ago

Patch set 1 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/40831

Actions #22

Updated by Mathias Brodala over 9 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #23

Updated by Benni Mack about 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF