[英]TYPO3: when/how to use define('TYPO3_MODE','FE');
/public_html/demo
is my TYPO3 site, i put a test.php
file under it, /public_html/demo
是我的 TYPO3 站点,我在它下面放了一个test.php
文件,
<?php
//define('TYPO3_MODE','FE');
require('typo3conf/localconf.php');
require('t3lib/class.t3lib_db.php');
require('t3lib/class.t3lib_div.php');
define('TYPO3_db_host', $typo_db_host);
define('TYPO3_db_username', $typo_db_username);
define('TYPO3_db_password', $typo_db_password);
define('TYPO3_db', $typo_db);
$DB = new t3lib_DB();
$DB->connectDB();
$result = mysql_query("SELECT * FROM fe_users WHERE username='tom_seeker'");
while($row = mysql_fetch_array($result))
{
echo $row['email'];
}
?>
Question:问题:
when need to put this line: define('TYPO3_MODE','FE');
当需要放这一行时:
define('TYPO3_MODE','FE');
? ? Here i comment it out, and script still works, so i just wonder when/how to use
define('TYPO3_MODE','FE');
在这里我将其注释掉,脚本仍然有效,所以我只是想知道何时/如何使用
define('TYPO3_MODE','FE');
? ?
Normally you define the TYPO3_MODE to tell the system if you are in the Frontend or Backend (FE vs BE).通常你定义 TYPO3_MODE 来告诉系统你是在前端还是后端(FE vs BE)。
Many Extensions ask the state of TYPO3_MODE.许多扩展会询问 TYPO3_MODE 的状态。
if (!defined ('TYPO3_MODE')) die ('Access denied.');
There should be no need to define this constant.应该没有必要定义这个常量。 TYPO3 will do it for you.
TYPO3 将为您完成。
Either build a plugin you can put on your site, or an eID
that does not need a site to function.要么构建一个可以放在站点上的插件,要么构建一个不需要站点即可运行的
eID
。 Both will give you the TYPO3 environment;两者都会给你 TYPO3 环境; the plugin a full one, the eID a smaller (and faster) one.
插件是一个完整的,eID 是一个更小(更快)的插件。
The question is quite old but people may still read here searching for answers (as did I).这个问题已经很老了,但人们可能仍然在这里阅读以寻找答案(我也是如此)。
Your (standalone) script is not running in any TYPO3 context.您的(独立)脚本未在任何 TYPO3 上下文中运行。
The (usual) way is to create an extension using existing TYPO3 API. (通常)方法是使用现有的 TYPO3 API 创建扩展。 TYPO3 will do some initialization for you which you then don't have to do yourself, such as autoloading classes, initializing backend and frontend users, language handling, resolving of URLs etc.
TYPO3 会为你做一些初始化,然后你不必自己做,比如自动加载类、初始化后端和前端用户、语言处理、URL 解析等。
If you do this, TYPO3_MODE will already be initialized.如果你这样做,TYPO3_MODE 将已经被初始化。 Read more about TYPO3_MODE in the Constants section .
在常量部分阅读有关TYPO3_MODE 的更多信息。 Note that most TYPO3 constants are being deprecated and have been replaced by the Environment class.
请注意,大多数 TYPO3 常量已被弃用并已被Environment类取代。
Read more about how to create an extension:阅读有关如何创建扩展的更多信息:
With the latest TYPO3 10 version, this is what you might do:使用最新的 TYPO3 10 版本,您可以这样做:
What you are trying to do above, may not even require an extension.您在上面尝试执行的操作甚至可能不需要扩展。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.