标签: extbase

TYPO3:在动作控制器中,如何判断动作是在后端执行还是在前端执行?

这可能很简单,但我不知道在哪里可以找到答案。假设在前端和后端中使用相同的操作,或者假设我需要在initializeAction前端和后端中使用不同的行为,我如何检查该操作是从后端调用还是从前端调用?

顺便说一句,我正在使用extbase和 TYPO3 6.1.0。

typo3 extbase

1
推荐指数
1
解决办法
2223
查看次数

Typo3 extbase:以编程方式更改记录 pid

我有一个 NewsRepository 和一个新闻模型。storagePid 是 74。我有一个脚本来检查新记录的结束时间字段是否过期。如果是,我想将记录移动到另一个文件夹(UID 170)中。

当我做:

$news = $newsRepository->findByUid( 1 );
$news->setTitle( 'News ' . rand(1,99999) );
$news->setPid( 170 );
$newsRepository->update( $news );
Run Code Online (Sandbox Code Playgroud)

标题变了,但PID没变。

那么,如何将新内容移动到另一页上呢?

typo3 move record parent extbase

1
推荐指数
1
解决办法
1751
查看次数

获取验证器中的设置-typo3

我有一个带有后端配置选项的扩展。我需要在 AddAction 和 UpdateAction 中验证电话号码。我可以在后端配置电话号码格式(例如美国电话号码/印度电话号码等)。我如何在验证器中获取设置?我有一个自定义验证器来验证电话号码。这是我的代码

    <?php
    namespace vendor\Validation\Validator;

    class UsphonenumberValidator extends \TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator
    {   


         protected $supportedOptions = array(
               'pattern' => '/^([\(]{1}[0-9]{3}[\)]{1}[ ]{1}[0-9]{3}[\-]{1}[0-9]{4})$/'
          );


          public function isValid($property) { 
                $settings = $this->settings['phone'];
                $pattern = $this->supportedOptions['pattern'];
                $match = preg_match($pattern, $property);

                if ($match >= 1) {
                    return TRUE;
                } else {
                $this->addError('Phone number you are entered is not valid.', 1451318887);
                    return FALSE;
                }

    }
} 
Run Code Online (Sandbox Code Playgroud)

$settings 返回 null

typo3 flux extbase

1
推荐指数
1
解决办法
659
查看次数

为typo3自定义扩展配置全屏后端模块

我是typo3扩展开发的新手,我也使用extension_builder创建了扩展以及后端模块。

ext_tables.php

if (TYPO3_MODE === 'BE') {

        \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
            'USER.Webuser',
            'web', // Make module a submodule of 'web'
            'bewebuser', // Submodule key
            '', // Position
            [
                'Users' => 'list, show, new, create, edit, update, delete',
            ],
            [
                'access' => 'user,group',
                'icon'   => 'EXT:' . $extKey . '/Resources/Public/Icons/user_mod_bewebuser.svg',
                'labels' => 'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_bewebuser.xlf',
            ]
        );

    }
Run Code Online (Sandbox Code Playgroud)

打字稿:

# Setting up template
module.tx_webuser_web_webuserbewebuser {
    persistence {
       storagePid = {$module.tx_webuser_bewebuser.persistence.storagePid}
    }
    view {
        templateRootPaths = EXT:webuser/Resources/Private/Backend/Templates/
        partialRootPaths = EXT:webuser/Resources/Private/Backend/Partials/
        layoutRootPaths = EXT:webuser/Resources/Private/Backend/Layouts/ …
Run Code Online (Sandbox Code Playgroud)

typo3 fluid typoscript extbase typo3-7.6.x

1
推荐指数
1
解决办法
1739
查看次数

如果 &lt;f:debug&gt; 返回字符串而不是对象,如何在 TYPO3 中进行调试?

在自定义 TYPO3 8.7.12 extbase 扩展中,我无法访问f:debug模板中的项目。

\n\n

我们在 listAction 控制器中,只需执行以下操作:

\n\n
    $institutions = $this->institutionRepository->findAll();\n    $this->view->assignMultiple([\n        \'institutions\' => $institutions,\n        // ... pagination limit ...\n        ]\n    );\n
Run Code Online (Sandbox Code Playgroud)\n\n

并在模板中:

\n\n
 <f:debug>\n    {institutions}                            \n </f:debug>\n
Run Code Online (Sandbox Code Playgroud)\n\n

这返回

\n\n
    \n
  • 有时流体调试器中的字符串“Array”(现在无法重现)
  • \n
  • 当代码有3行时:#1273753083: Cannot cast object of type "TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QueryResult" to string.
  • \n
  • 或者也#1273753083: Cannot cast object of type "TYPO3\\CMS\\Extbase\\Persistence\\Generic\\LazyObjectStorage" to string.
  • \n
  • 当代码在 1 行时:#1234386924: Cannot create empty instance of the class "TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage" because it does not implement the TYPO3\\CMS\\Extbase\\DomainObject\\DomainObjectInterface. …

typo3 fluid extbase typo3-8.7.x

1
推荐指数
1
解决办法
2565
查看次数

$query 组合嵌套约束

我有以下查询:

$query = $this->createQuery();
$constraint = [];
$constraint[] = $query->like('title', '%' . $searchTerm . '%');
$constraint[] = $query->like('description', '%' . $searchTerm . '%');
$query->matching($query->logicalOr($constraint));
Run Code Online (Sandbox Code Playgroud)

这个查询有效。现在我有一个新的约束,我想添加它locigalAnd。我怎样才能做到这一点?

新的约束是:

$constraint[] = $query->contains('categories', $myCategory);
Run Code Online (Sandbox Code Playgroud)

我怎样才能将它们结合起来?

typo3 extbase

1
推荐指数
1
解决办法
92
查看次数

在 Symfony 命令中使用 Extbase 存储库

我正在升级一个扩展以与 TYPO3 v10 一起使用。由于命令控制器不能再使用,我将它们迁移到文档中指出的 symfony 命令。除了使用 extbase 存储库类之外,一切都运行顺利。无论我查询什么,我都不会得到结果。由于我在网络和文档上找不到任何有用的信息,我希望这可能只是一些小问题。

经过一段时间的调试后,我发现在构建查询设置时没有正确确定 pid。我觉得这很奇怪,因为我的根模板有这些行:

plugin.tx_myext.persistence.storagePid = 15403
module.tx_myext.persistence.storagePid = 15403
Run Code Online (Sandbox Code Playgroud)

存储库实例通过injectMyRepository() 方法正确注入。我尝试使用 extbase ObjectManager 来获取类实例,但“错误”保持不变。

我是否做错了什么或者是否无法在 symfony 命令中使用 extbase 存储库类?

typo3 extbase symfony-console typo3-10.x

1
推荐指数
1
解决办法
719
查看次数

扩展构建器覆盖fe_user TCA

如果我尝试通过在Typo3 6.1.7的扩展程序构建器上创建新的模型对象来扩展fe_user表,它将通过在扩展程序的ext_tables.php中写入这些行来覆盖TCA:

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('fe_users', 'EXT:voiwizard/Resources/Private/Language/locallang_csh_fe_users.xlf');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('fe_users');
$TCA['fe_users'] = array(
    'ctrl' => array(
        'title' => 'LLL:EXT:voiwizard/Resources/Private/Language/locallang_db.xlf:fe_users',
        'label' => 'prova',
        'tstamp' => 'tstamp',
        'crdate' => 'crdate',
        'cruser_id' => 'cruser_id',
        'dividers2tabs' => TRUE,

        'versioningWS' => 2,
        'versioning_followPages' => TRUE,
        'origUid' => 't3_origuid',
        'languageField' => 'sys_language_uid',
        'transOrigPointerField' => 'l10n_parent',
        'transOrigDiffSourceField' => 'l10n_diffsource',
        'delete' => 'deleted',
        'enablecolumns' => array(
            'disabled' => 'hidden',
            'starttime' => 'starttime',
            'endtime' => 'endtime',
        ),
        'searchFields' => 'prova,',
        'dynamicConfigFile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Configuration/TCA/User.php',
        'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($_EXTKEY) . 'Resources/Public/Icons/fe_users.gif'
    ),
);
Run Code Online (Sandbox Code Playgroud)

此代码将覆盖原始fe_users的TCA配置,并且后端[网站用户] [1]表将变得不可访问。有什么方法可以防止这种情况,还是每次我想在扩展构建器中保存更改时都必须删除这些行?

typo3 extbase

0
推荐指数
1
解决办法
1734
查看次数

在流体模板中解析现有的JSON字符串?

我有一个JSON字符串,其中包含我想在模板中呈现的一些数据.由于Fluid数组也以JSON标注,我想我可能只需要接受JSON字符串并将其交给流体,告诉它像处理其他数组一样处理它并在模板中使用它.

因此获得了大量的速度并且失去了开销(不必将JSON数据拆分以将其保存在DB中,可以轻松地将其模板化为流畅的).

它不起作用,至少不是我如何尝试它.

<f:alias map="{item.jsonData}">
  {fieldname}
</f:alias>
Run Code Online (Sandbox Code Playgroud)

它 - 当然 - 抱怨它收到了一个字符串,而不是一个数组.

json_decode在将数组返回流体之前,是否必须构建一个viewhelper ?还是有更原生的方式?

这是基本的控制器动作:

/**
 * action show
 *
 * @param \NAMESPACE\Myext\Domain\Model\Item $item
 * @return void
 */
public function showAction(\NAMESPACE\Myext\Domain\Model\Item $item) {
    $this->view->assign('item', $item);
}
Run Code Online (Sandbox Code Playgroud)

typo3 fluid extbase typo3-6.2.x

0
推荐指数
1
解决办法
2769
查看次数

扩展安装预填表

嗨我想在扩展安装期间添加一些数据...

我在创建表后添加了一条SQL语句,但在安装过程中会被忽略.

#
# Insert für start einstellungen
#
INSERT INTO tx_rere_domain_model_intervall (type,aktuell) VALUES ('studienhalbjahr','WS14/15');
Run Code Online (Sandbox Code Playgroud)

此代码直接位于Create Statement之后 tx_rere_domain_model_intervall

更新:#TYPO3 Extension Manager转储1.1 ## ---------------------------------------- ----------------

#
# Table structure for table 'tx_rere_domain_model_interval'
#
DROP TABLE IF EXISTS tx_rere_domain_model_intervall;
CREATE TABLE tx_rere_domain_model_intervall (
uid int(11) NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,

type varchar(255) DEFAULT '' NOT NULL,
aktuell varchar(255) DEFAULT '' NOT NULL,

tstamp int(11) unsigned DEFAULT '0' NOT NULL,
crdate int(11) unsigned DEFAULT '0' NOT NULL,
cruser_id int(11) …
Run Code Online (Sandbox Code Playgroud)

typo3 extbase typo3-6.2.x

0
推荐指数
1
解决办法
416
查看次数