如何在StandaloneView中渲染INT_SCRIPT? [英] How to render INT_SCRIPT in StandaloneView?

查看:54
本文介绍了如何在StandaloneView中渲染INT_SCRIPT?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用cObject ViewHelper在独立视图中渲染TypoScript对象.该TS对象当前从其他页面获取tt_content.但是结果具有INT_SCRIPT标记,而不是实际内容.

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.

这是有关如何制作独立视图,模板和TypoScript的代码:

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

内部控制器:

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:

TypoScript:

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

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

流体:

<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.

那么我该如何解析包含非缓存内容的独立视图并且不插入INT_SCRIPT标记?

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

谢谢你!

推荐答案

找到了解决方案.也许这不是解决该问题的最佳方法.但是目前,它工作正常.

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;
}

供您参考.我需要它来处理页面中的内容并通过邮件发送它们或使用外部工具呈现pdf.但是某些内容或页面仅适用于当前用户(不适用于组或另一个用户).而且我也不想在控制器内登录该用户.我认为这是处理该问题的最佳方案.

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 :-)

这篇关于如何在StandaloneView中渲染INT_SCRIPT?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆