【问题标题】:The requested view was not found in TYPO3在 TYPO3 中找不到请求的视图
【发布时间】:2016-12-04 21:11:30
【问题描述】:

我的控制器位于文件夹控制器中,名称为 AdController 我的动作名称是

/**
 * action ajaxValue
 *
 * @param string $argument 
 * @return void
 */
public function ajaxValueAction($argument = NULL) {

 }

我的模板文件位于 Resources/Private/Templates/Ad/ajaxValue.html 名称为 ajaxValue.html

{namespace t=Helhum\TyposcriptRendering\ViewHelpers}

<f:layout name="Default" />



This Template is responsible for creating a table of domain objects.

If you modify this template, do not forget to change the overwrite settings
in /Configuration/ExtensionBuilder/settings.yaml:
Resources:
Private:
Templates:
List.html: keep

Otherwise your changes will be overwritten the next time you save the extension in the extension builder

<f:section name="main">
    <f:debug title="Results of customers query">{ads}</f:debug>
    <f:flashMessages />

    <!-- Category selection box -->


    <!-- This is basically called a ajax request which is based on some other file take from the following link http://ajax.helmut-hummel.de/

-->

    <div id="dataJson" data-url="{t:uri.ajaxAction(action: 'ajaxValue', format: 'json', controller: 'Ad', pluginName: 'Txcasmarketing') -> f:format.htmlentities()}"></div>

    <div class="container">
         <div class="btn-group">
            <a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#">Select Category<span class="caret"></span></a>
            <ul class="dropdown-menu">
                <f:for each="{categories}" as="category">
                    <li>
                        <a data-catUid="{category.uid}" href="#">{category.name}</a>
                    </li>
                </f:for>
            </ul>
        </div>
     </div>

我收到以下错误

  <p><strong>Sorry, the requested view was not found.</strong></p> <p>The technical reason is: <em>No template was found. View could not be resolved for action "ajaxValue"  in class "CASmarketing\Casmarketing\Controller\AdController"</em>.</p>

扩展生成器创建的默认模板是可访问的。我的 ex_localconf.php 的结构是

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
        'CASmarketing.Casmarketing', 
        'Txcasmarketing', [
            'State' => 'list, show, new, create, edit, update, delete',
            'Category' => 'list, show, new, create, edit, update, delete',
            'Ad' => 'list, ajaxValue, show, new, create, edit, update, delete'
        ],
        // non-cacheable actions
        [
            'State' => 'create, update, delete',
            'Category' => 'create, update, delete',
            'Ad' => 'create, update, delete'
        ]
);
}, $_EXTKEY
);

我的模板文件位于 Resources/Templates/Ad/ajaxValue.html

名称为 ajaxValue.html

我的 step.ts 文件是

 plugin.tx_casmarketing_txcasmarketing {
     view {
  templateRootPaths.0 = EXT:casmarketing/Resources/Private/Templates/
  templateRootPaths.1 =              {
    $plugin.tx_casmarketing_txcasmarketing.view.templateRootPath}
   partialRootPaths.0 = EXT:casmarketing/Resources/Private/Partials/
  partialRootPaths.1 =   {
      $plugin.tx_casmarketing_txcasmarketing.view.partialRootPath}
   layoutRootPaths.0 = EXT:casmarketing/Resources/Private/Layouts/
  layoutRootPaths.1 = {
 $plugin.tx_casmarketing_txcasmarketing.view.layoutRootPath}
 }
 persistence {
   storagePid = {
  $plugin.tx_casmarketing_txcasmarketing.persistence.storagePid}
  #recursive = 1
  }
 features {
  #skipDefaultArguments = 1
    }
   mvc {
     #callDefaultActionIfActionCantBeResolved = 1
       }
          }

我的脚本文件,基本上称为 ajax 请求,在 pageLayout.js 中定义

$(".dropdown-menu li a").click(function () {

    var jsonUrl = $('#dataJson').attr('data-url')
    var selectedCatUid = $(this).attr('data-catUid');

    $.ajax({
        type: 'POST',
        url: jsonUrl,
        data: {
            'tx_casmarketing_txcasmarketing[catId]': selectedCatUid
        },
        success: function (response) {
            alert(response);
        },
    });

【问题讨论】:

  • 我把它改成大写它仍然是一样的,我提到了我的 step.ts 文件。它不接受任何其他操作,除了扩展生成器提供的默认值???

标签: typo3 extbase typo3-7.6.x


【解决方案1】:

您的模板不应位于Resources/Templates/Ad/ajaxValue.html 中,而应位于Resources/Private/Templates/Ad/AjaxValue.html 中。注意 Private 子文件夹。它也必须是大写。

【讨论】:

  • 它已经在 Resources/Private/Templates/Ad/AjaxValue.html 可能我的错误我没有提到...
  • 我进一步解释我的问题可能对你来说更清楚......我提到了我的模板文件
  • 我可以和你聊天吗。你能准确地看到我的问题吗?这将是你的好意......
  • 您可以随时加入 Slack 上的 TYPO3 社区,并在那里以更健谈的方式提出您的问题,只要您之后更新此问题,以便解决方案能够持续存在。
【解决方案2】:

不知道这很重要,但文件名通常是大写的。您还应该确保将打字设置配置到此目录。

【讨论】:

  • 我把它改成大写它仍然是一样的,我提到了我的 step.ts 文件。它不接受任何其他操作,除了扩展生成器提供的默认值???
  • 你的 ext_localconf 是正确的,否则你会得到另一个错误。您的打字稿语法错误。 .1 与 { 嵌套,但您不能这样做,因为它不是带有嵌套的打字稿对象,您必须直接放入路径中。
  • 啊等等,我看到它是一个常数,但它必须在 {s 之间没有空格
  • 但它使用的是由扩展生成器生成的默认模板。在我的情况下, list.html 额外的工作正常。您能否重写建议的更改,以便我可以清楚地理解谢谢
【解决方案3】:

您的打字稿应该如下所示:

plugin.tx_casmarketing_txcasmarketing {
  view {
    templateRootPaths.0 = EXT:casmarketing/Resources/Private/Templates/
    templateRootPaths.1 = {$plugin.tx_casmarketing_txcasmarketing.view.templateRootPath}

    partialRootPaths.0 = EXT:casmarketing/Resources/Private/Partials/
    partialRootPaths.1 = {$plugin.tx_casmarketing_txcasmarketing.view.partialRootPath}

    layoutRootPaths.0 = EXT:casmarketing/Resources/Private/Layouts/
    layoutRootPaths.1 = {$plugin.tx_casmarketing_txcasmarketing.view.layoutRootPath}
  }

  persistence {
    storagePid = {$plugin.tx_casmarketing_txcasmarketing.persistence.storagePid}
    #recursive = 1
  }

  features {
    #skipDefaultArguments = 1
  }

  mvc {
    #callDefaultActionIfActionCantBeResolved = 1
  }
}

如果您在扩展的 setup.txt 中更改此内容,则几乎不会缓存,您必须在安装工具中清除缓存。在确保正确加载了您的打字稿后,首先将新的 Views 模板放在 ext-directory 模板路径中进行尝试。

如果这没有帮助,请将您的 HTML 模板的内容提供给我们。

【讨论】:

  • 我的 stepup.ts 文件的写法一模一样,你在 up cmets 中提到了什么......没有任何改变......我可以提到我的模板文件。基本上在 List.html 文件中有一个下拉选项框,我选择一个值,然后将 ajax 请求转到控制器,控制器必须执行查询以将值返回到另一个模板文件或完全相同的 list.html更新值。我可以更新我的主要问题你可以看到我如何从列表模板调用控制器的完整描述.....
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-07
  • 2018-08-29
  • 2021-12-09
  • 1970-01-01
相关资源
最近更新 更多