简体   繁体   English

如果启用了realURL,则TYPO3流动形式不起作用

[英]TYPO3 fluid form not working if realURL is enabled

I have created a car extension which contains a list view and a detail view. 我创建了一个汽车扩展程序,其中包含一个列表视图和一个详细视图。 The detail view also contains a contact form. 详细视图还包含一个接触的形式。 This extensions works fine with realURL disabled, but for SEO friendly urls I have enabled and configured realURL so I got the following behaviour for my urls: 此扩展正常工作与realURL禁用,但对搜索引擎友好的URL我已经启用并配置realURL所以我得到了我的网址以下行为:

list view 列表显示

domain.de/index.php?id=3 -> domain.de/cars/

detail view 详细视图

domain.de/index.php?id=38 -> domain.de/cars/details/

detail view + get parameter car 详细视图+获取参数车

domain.de/index.php?id=38&car=200 -> domain.de/cars/details/{brand-model}/

So the URL rewriting is working correctly and my extension anchors from list view to detail view also works as expected, but my contact form on the detail view is not working anymore. 因此,URL重写工作正常,并从列表视图我的分机锚详细视图也按预期工作,但我的联系表格上的细节视图不再工作。

Fluid markup of my form 我的形式的流体标记

<f:form action="send" method="post" name="request" section="form" object="{request}">
    <fieldset>
        <label>Salutation<span class="required">*</span>
            <f:render partial="FormErrors" arguments="{field: 'request.salutation'}" />
        </label>
        <f:form.hidden property="salutation" />
        <label>
            <f:form.radio property="salutation" value="female" />Frau
        </label>
        <label>
            <f:form.radio property="salutation" value="male" />Herr
        </label>
    </fieldset>
    <fieldset>
        <label for="name">Name<span class="required">*</span>
             <f:render partial="FormErrors" arguments="{field: 'request.name'}" />
        </label>
        <f:form.textfield property="name" />
    </fieldset>

    ....

    <fieldset>
         <f:form.submit class="button" name="send" value="Send" />
    </fieldset>
</f:form>

If I inspect this form with developer tools I got the following markup: 如果我检查这种形式与开发工具,我得到了下面的标记:

with realURL enabled 启用realURL

<form method="post" name="request" action="cars/details/?tx_foxcars_p1%5Baction%5D=send&amp;cHash=f654ce4fb67a5b5c636508675c18d4c3#form">

with realURL disabled 与realURL禁用

<form method="post" name="request" action="index.php?id=38&tx_foxcars_p1%5Baction%5D=send&cHash=f654ce4fb67a5b5c636508675c18d4c3#form">

I think that is ok, but if I submit the form with realURL enabled I got the content of my 404 page. 我认为这是好的,但如果我提交表单与realURL使我得到了我404页的内容。 With realURL disabled it is working as expected. 禁用realURL后,它会按预期运行。

My sendAction looks as follows: 我sendAction如下所示:

public function sendAction(\Fox\FoxCars\Domain\Model\Request $request)
{
    $fromEmail = $request->getEmail();
    $fromName = $request->getName();
    $toEmail = $this->settings['senderEmail'];
    $toName = $this->settings['senderName'];
    $subject = $this->settings['subject'];
    $body = $request->getBody();

    $mail = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
    $mail->setFrom(array($fromEmail => $fromName));
    $mail->setTo(array($toEmail => $toName));
    $mail->setSubject($subject);
    $mail->setBody($body, 'text/html');
    $mail->send();

    if ($mail->isSent()) {
        $this->redirect('send', null, null, null, $this->settings['confirmPageId']);
    }
}

But it seems that this action will not be executed if realURL is enabled. 但似乎如果启用realURL这一行动将不会被执行。

My realURL configuration looks as follows: 我realURL配置如下所示:

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'] = array(
    '_DEFAULT' => array(
        'init' => array(
            'enableCHashCache' => true,
            'appendMissingSlash' => 'ifNotFile,redirect',
            'adminJumpToBackend' => true,
            'enableUrlDecodeCache' => true,
            'enableUrlEncodeCache' => true,
            'respectSimulateStaticURLs' => false,
            'emptyUrlReturnValue' => '/',
        ),
        'pagePath' => array(
            'type' => 'user',
            'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
            'spaceCharacter' => '-',
            'languageGetVar' => 'L',
            'rootpage_id' => '1',
        ),
        'fileName' => array(
            'defaultToHTMLsuffixOnPrev' => 0,
            'acceptHTMLsuffix' => 1,
            'index' => array(
                'print' => array(
                    'keyValues' => array(
                        'type' => 98,
                    ),
                ),
            ),
        ),
        'fixedPostVars' => array(
            'carsDetailConfiguration' => array(
                array(
                    'GETvar' => 'car',
                    'lookUpTable' => array(
                        'table' => 'tx_foxcars_domain_model_car',
                        'id_field' => 'uid',
                        'alias_field' => "CONCAT(brand, '-', model)",
                        'addWhereClause' => ' AND NOT deleted',
                        'useUniqueCache' => 1,
                        'useUniqueCache_conf' => array(
                            'strtolower' => 1,
                            'spaceCharacter' => '-'
                        ),
                        'languageGetVar' => 'L',
                        'languageExceptionUids' => '',
                        'languageField' => 'sys_language_uid',
                        'transOrigPointerField' => 'l10n_parent'
                    )
                )
            ),
            '38' => 'carsDetailConfiguration',
            'newsDetailConfiguration' => array(
                array(
                    'GETvar' => 'tx_news_pi1[news]',
                    'lookUpTable' => array(
                        'table' => 'tx_news_domain_model_news',
                        'id_field' => 'uid',
                        'alias_field' => 'title',
                        'useUniqueCache' => 1,
                        'useUniqueCache_conf' => array(
                            'strtolower' => 1,
                            'spaceCharacter' => '-',
                        ),
                    ),
                ),
            ),
            '35' => 'newsDetailConfiguration',
        ),
        'postVarSets' => array(
            '_DEFAULT' => array(
                'news' => array(
                    0 => array(
                        'GETvar' => 'tx_news_pi1[news]',
                        'lookUpTable' => array(
                            'table' => 'tx_news_domain_model_news',
                            'id_field' => 'uid',
                            'alias_field' => 'title',
                            'useUniqueCache' => 1,
                            'useUniqueCache_conf' => array(
                                'strtolower' => 1,
                                'spaceCharacter' => '-',
                            ),
                        ),
                    ),
                ),
                'cars' => array(
                    0 => array(
                        'GETvar' => 'car',
                        'lookUpTable' => array(
                            'table' => 'tx_foxcars_domain_model_car',
                            'id_field' => 'uid',
                            'alias_field' => "CONCAT(brand, '-', model)",
                            'useUniqueCache' => 1,
                            'useUniqueCache_conf' => array(
                                'strtolower' => 1,
                                'spaceCharacter' => '-',
                            ),
                        ),
                    ),
                ),
            ),
        ),
    ),
);

Maybe is there a misconfiguration with realURL? 也许是那里realURL配置错误? So realURL expect the get parameter "car", but only get the send action? 所以realURL期待的get参数“车”,但只得到了发送动作? So car is missing and not found -> 404? 因此,缺少汽车并找不到-> 404?

Hope you can help me :) 希望你能帮我 :)

I forgot to add 我忘了加

additionalParams="{car: car}"

to my form. 到我的形式。 So I changed 所以我改变了

<f:form action="send" method="post" name="request" section="form" object="{request}">

to

<f:form action="send" additionalParams="{car: car}" method="post" name="request" section="form" object="{request}">

and it is working now :). 它现在正在工作:)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM