typo3 - 通过 TypoScript 生成随机字符串

标签 typo3 typoscript

是否可以通过 TypoScript 自动生成数字和字母的混合字符串,例如12A54或类似的东西?

最佳答案

与 php 包含脚本相比,我更喜欢 userFunc。例如,您可以将参数传递给用户函数。

排版:

includeLibs.generateInvoiceNo= fileadmin/scripts/generateInvoiceNo.php
temp.invoiceNo = USER
temp.invoiceNo {
  userFunc =user_generateInvoiceNo->main
}

PHP:
fileadmin/scripts/generateInvoiceNo.php
<?
class user_generateInvoiceNo {
    var $cObj;// The backReference to the mother cObj object set at call time
    /**
    * Call it from a USER cObject with 'userFunc = user_generateInvoiceNo->main'
    */
    function main($content,$conf){
        $length = 6;
        $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        $number=substr(str_shuffle($chars),0,$length);
        return $number;
    }
}
?>

学分:
  • This php script
  • TYPO3 Wizard on userFunc
  • 关于typo3 - 通过 TypoScript 生成随机字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12972853/

    相关文章:

    seo - 在 TYPO3 中使用 tt_news、RealURL 和 RSS 生成正确的 URL

    authentication - Typo3 版本 8 登录循环

    typo3 - 如何在 Action 中呈现另一个 Controller 的 methodAction

    php - 如何在 Typo3 CMS 中配置语言菜单

    typo3 - 我可以在我的 TYPO3 扩展中将 setup.txt 重命名为 setup.ts(和常量)吗?

    plugins - TYPO3 4.7.2 通过 typescript 包含 extbase 插件

    typo3 - 如何 : find the length of a typoscript defined array in fluid?

    javascript - 有没有办法将样式表或 javascript 文件动态添加到包含插件的 TYPO3 页面?

    mysql - TYPO3 MySQL 选择查询,在 phpMyAdmin 中有效,但在 TYPO3 中无效

    docker - TYPO3 可以在没有本地文件存储 typo3temp 目录的情况下运行吗?