在TYPO3中找不到请求的视图

时间:2016-12-04 21:11:30

标签: typo3 extbase typo3-7.6.x

我的控制器位于文件夹控制器中,名称为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/

- &GT;

    <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”)。点击(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);
        },
    });

1 个答案:

答案 0 :(得分:0)

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