0

I'm rendering in an standalone view a TypoScript Object with the cObject ViewHelper. That TS Object gets tt_content from other pages currently. But the result has the INT_SCRIPT markers and not the real content.

here's my code on how to make the standalone view, the template and the TypoScript:

Inside controller:

public function renderStandaloneView($template = 'View/Show', $variables = array(), $fileExt = 'html', $noCache = TRUE) {
    if ( $noCache === TRUE ) $GLOBALS['TSFE']->set_no_cache();

    // Get standalone view
    $configuration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
    $view          = $this->objectManager->get(StandaloneView::class);

    $view->getRequest()->setControllerExtensionName($this->extensionName);
    $view->setFormat($fileExt);
    $view->setLayoutRootPaths($configuration['view']['layoutRootPaths']);
    $view->setPartialRootPaths($configuration['view']['partialRootPaths']);
    $view->setTemplateRootPaths($configuration['view']['templateRootPaths']);
    $view->setTemplate($template);

    // Render view
    $view->assignMultiple($variables);

    return $view->render();
}

TypoScript:

lib.myContent = COA
lib.myContent {
  10 = CONTENT
  10 {
    table = tt_content

    select {
        orderBy         = sorting
        where           = 0
        where.wrap      = colPos=|
        pidInList.field = uid
    }
  }
}

Fluid:

<f:for each="{myvars}" as="myvar" iteration="it">
  <f:cObject typoscriptObjectPath="lib.myContent" data="{uid:'{myvar.uid}'}" />
</f:for>

I cannot change all the uncached elements (like content elements / plugins) on that pages to be cached.

So how can i parse the standalone view including the non cached content and not insert the INT_SCRIPT markers?

Thanks for anything!

HR123
  • 688
  • 1
  • 6
  • 15
  • 2
    I don‘t think this will fix the whole of your problem but nonetheless you should start removing `$GLOBALS['TSFE']->set_no_cache()` from your method. This will disable all page cache for the current request. Don‘t use this `set_no_cache` for **anything** you want to release to the wild! – undko Mar 21 '17 at 21:12
  • Thanks for that hint. I've changed it. As expected it didn't resolves my problem. – HR123 Mar 22 '17 at 07:24
  • I've been trying to figure out what you're trying to do here for the past 10 minutes. Without avail. This condition: if ( $noCache === TRUE ) $GLOBALS['TSFE']->set_no_cache(); obviously can't work. Because if your content is cached once, the condition wont even be checked anymore. The call to ExtensionUtility::configurePlugin in your ext_localconf.php defines, per action, if the content is cached. – j4k3 Mar 22 '17 at 09:18

1 Answers1

0

Found a solution. Maybe it isn't the best way to resolve that problem. But at the moment it works fine.

public function renderStandaloneView($template = 'View/Show', $variables = array(), $fileExt = 'html') {
    // Get standalone view
    $configuration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
    $view          = $this->objectManager->get(StandaloneView::class);

    $view->getRequest()->setControllerExtensionName($this->extensionName);
    $view->setFormat($fileExt);
    $view->setLayoutRootPaths($configuration['view']['layoutRootPaths']);
    $view->setPartialRootPaths($configuration['view']['partialRootPaths']);
    $view->setTemplateRootPaths($configuration['view']['templateRootPaths']);
    $view->setTemplate($template);

    // Render view
    $view->assignMultiple($variables);

    // Handle the INT_SCRIPT markers
    $content = $view->render();
    $contentBak = $GLOBALS['TSFE']->content;
    $GLOBALS['TSFE']->content = $content;
    $GLOBALS['TSFE']->INTincScript();
    $content = $GLOBALS['TSFE']->content;
    $GLOBALS['TSFE']->content = $contentBak;
    unset($contentBak);

    return $content;
}

For your information. I need this to handle content from pages and send them by mail or render a pdf with an external tool. But some content or pages are only available for the current user (not a group or another user). And i didn't want to login that user inside the controller or else. i think that's the best case to handle that.

Other solutions are still welcome :-)

HR123
  • 688
  • 1
  • 6
  • 15
  • 1
    Why didn't you say so? You're invoking a StandaloneView just to invoke TypoScript for content rendering. Holy crap. This is how you render content from inside an Extension: http://stackoverflow.com/questions/20283998/how-i-can-render-content-object-from-tt-content-i-my-extension-with-php-in-typo3 – j4k3 Mar 22 '17 at 16:00
  • Yeah i know it looks like a "holy crap", just to render TypoScript. I can not explain you the whole project, but in my case it's needed to use it over the StandaloneView way. Thanks a lot for your hint anyway! Alternative way (like your way) could be just call the contentRendererObject and use FLUIDTEMPLATE in the TS Object. – HR123 Mar 22 '17 at 19:07