0
votes

I have my controller in the folder controllers with the name AdController and my action name is

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

 }

and my template file is on location Resources/Private/Templates/Ad/ajaxValue.html with the name 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>

I am getting the following error

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

The defaults templates which has been created by extension builder is accessible. the structure of my ex_localconf.php is

\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
);

and my template file is on location Resources/Templates/Ad/ajaxValue.html

with the name ajaxValue.html

and my step.ts file sitting is

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

my script file which is basically called the ajax request which is define in the 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);
        },
    });
3
I change it to capital it is still the same and i menioned my step.ts file. it does not accept any other action except then the defult which has been provided by extension builder???zahid

3 Answers

1
votes

Your template should not be in Resources/Templates/Ad/ajaxValue.html but in Resources/Private/Templates/Ad/AjaxValue.html. Mind the Private sub folder. Also it has to be UpperCase.

0
votes

Didn't know that it does matter but the filename usually is uppercase. You also should make sure that the typoscript settings are configured to this directory.

0
votes

Your typoscript should correctly look like this:

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

If you change this in your setup.txt of the extension this is hardly cached and you have to clear the cache in the install tool. After making sure your typoscript is correctly loaded place your new Views template inside the ext-directory template path first to try it out.

If this does not help please give us the content of your HTML Template.