typo3

Special settings for TYPO3 localconf.php

When you set up a new installation of TYPO3 experienced installers will make changes to the typo3conf/localconf.php  file either manually or through the install tool.

I have listed my regular changes with discussion:

$TYPO3_CONF_VARS[‘GFX’][‘jpg_quality’] = ’80’;

I find that the default TYPO3 output of jpegs contain too many artifacts so I increase the quality slightly.

$TYPO3_CONF_VARS[‘GFX’][‘TTFLocaleConv’] = ‘UTF-8’;
$TYPO3_CONF_VARS[‘SYS’][‘UTF8filesystem’] = ‘1’;
$TYPO3_CONF_VARS[‘SYS’][‘multiplyDBfieldSize’] = ‘2’;
$TYPO3_CONF_VARS[‘BE’][‘forceCharset’] = ‘utf-8’;

In most cases using UTF-8 is the most sensible suggestion for character encoding as it encompases the widest range of characters. I remain puzzled why TYPO3 does not default to UTF-8.

$TYPO3_CONF_VARS[‘GFX’][‘TTFdpi’] = ’96’;

Most modern hosting comes with Gdlib2 so this should be set to 96dpi. I don’t know why TYPO3 does not set this by default.

$TYPO3_CONF_VARS[‘SYS’][‘curlUse’] = ‘1’;

When TYPO3 fetches external pages – using cURL is just a little bit quicker so enable it if available.

$TYPO3_CONF_VARS[‘SYS’][‘setMemoryLimit’] = ’64’;

Although this setting is probably set atserver level some configurations allow you to over-ride it here in the localconf.php so set it to something sensible. Most modern servers have a good amount of RAM available.

$TYPO3_CONF_VARS[‘SYS’][‘systemLogLevel’] = ‘1’;

This reduces the amount of logging slightly – can be set higher to reduce load slightly.

$TYPO3_CONF_VARS[‘EXT’][‘noEdit’] = ‘0’;

I am always tweaking/editing extension files so this setting allows you to do this within the TYPO3 extension manager.

$TYPO3_CONF_VARS[‘BE’][‘RTE_imageStorageDir’] = ‘fileadmin/user_upload/’;

I have never understood why TYPO3 defaults the user upload to a directory outside the accessible fileadmin folder. So set this and you’ll be able to access the files that people upload more easily from the TYPO3 backend.

$TYPO3_CONF_VARS[‘BE’][‘warning_email_addr’] = ’email@domain.com’;

This allows you to receive emails when failed attempts to log in are detected. This is useful to help spot bad behaviour but more often I see clients forgetting their log-ins so I help them out by reminding them pro-actively!

$TYPO3_CONF_VARS[‘BE’][‘warning_mode’] = ‘2’;

Set this so that you get an email if an admin user logs in. It includes yourself of course.

$TYPO3_CONF_VARS[‘BE’][‘lockIP’] = ‘3’;

I reduce this from the default of 4 as my ISP tweaks my IP address part way through sessions. Sometimes they change my IP completely and it stops my session being maintained so if this happens you’d need to reduce this amount to 0.

$TYPO3_CONF_VARS[‘BE’][‘sessionTimeout’] = ‘3600*24*365’;

I get annoyed when TYPO3 keeps popping up my alerts and logging me out when I work on a site for long hours so this helps reduce the nags.

$TYPO3_CONF_VARS[‘BE’][‘compressionLevel’] = ‘2’;

This compresses theTYPO3 backend and helps speed things up a bit.

$TYPO3_CONF_VARS[‘BE’][‘interfaces’] = ‘backend,frontend’;

I like to have the option to login to the backend and the frontend. This option gives you the choice when you login.

$TYPO3_CONF_VARS[‘BE’][‘accessListRenderMode’] = ‘checkbox’;

This is a special tweak that helps you to see better what each access control item is and uses check boxes instead of that slightly tricky combo box.

$TYPO3_CONF_VARS[‘FE’][‘logfile_dir’] = ‘fileadmin/logs’;

Set your typo3 log directory somewhere you can easily see the files.

$TYPO3_CONF_VARS[‘FE’][‘publish_dir’] = ‘/’;

For me this is the coolest modification and so few developers use it! It allows you to publish a static version of your web pages as real html and dynamically alongside pages that are not published. Speeds up page delivery more than normal TYPO3 caching.

$TYPO3_CONF_VARS[‘FE’][‘compressionLevel’] = ‘2’;

This compresses the front end to speed up the page slightly.

$TYPO3_CONF_VARS[‘FE’][‘pageNotFound_handling’] = ‘READFILE:fileadmin/notfound.html’;

At last TYPO3 serves up good 404 page handling  – I need to test this fully and provide a useful tutorial.

$TYPO3_CONF_VARS[‘FE’][‘lifetime’] = ‘3600*24*7*52’;

Set longer cookie lengths for your logged in website visitors.

$TYPO3_CONF_VARS[‘FE’][‘dontSetCookie’] = ‘1’;

I always set this on sites that do not use front end log ins. The reason – it stops the cookie nag in some browsers and can put people off entering the site.

$TYPO3_CONF_VARS[‘FE’][‘pageCacheToExternalFiles’] = ‘1’;

This creates a static html page of the cached TYPO3 output and will speed up the delivery of the page to the browser. Files are stored in /typo3temp/cachedfiles/ I’ve not tested it fully yet but so far seems to work fine. On clearing cache the old pages are not deleted so better clear out this folder from time to time is server space is an issue.

www.aoline.com


Typo3-windwos下安装ImageMagick注意事项

localconf.php里:

$TYPO3_CONF_VARS[‘GFX’][‘im_path’] = ‘D:\\ImageMagick\\ImageMagick-6.6.0-Q16\\’;    // Modified or inserted by TYPO3 Install Tool.
$TYPO3_CONF_VARS[‘GFX’][‘im_path_lzw’] = ‘D:\\ImageMagick\\ImageMagick-6.6.0-Q16\\’;    // Modified or inserted by TYPO3 Install Tool.

注意:这里不能用Program Files路径,因为有 空格 ,windows下路径不能有空格

php.ini

extension=php_imagick_st-Q16.dll

php/ext/php_imagick_st-Q16.dll


eval-list of keywords

Configuration of field evaluation.

Some of these evaluation keywords will trigger a JavaScript pre-evaluation in the form. Other evaluations will be performed in the backend.

The eval-functions will be executed in the list-order.

Keywords:

  1. required : A non-empty value is required in the field (otherwise the form cannot be saved).

  2. trim : The value in the field will have whitespaces around it trimmed away.

  3. date : The field will evaluate the input as a date, automatically converting the input to a UNIX-time in seconds. The display will be like "12-8-2003" while the database value stored will be "1060639200".

  4. datetime : The field will evaluate the input as a date with time (detailed to hours and minutes), automatically converting the input to a UNIX-time in seconds. The display will be like "16:32 12-8-2003" while the database value will be "1060698720".

  5. time : The field will evaluate the input as a timestamp in seconds for the current day (with a precision of minutes). The display will be like "23:45" while the database will be "85500".

  6. timesec : The field will evaluate the input as a timestamp in seconds for the current day (with a precision of seconds). The display will be like "23:45:13" while the database will be "85513".

  7. year : Evaluates the input to a year between 1970 and 2038. If you need any year, then use "int" evaluation instead.

  8. int : Evaluates the input to an integer.

  9. upper : Converts to uppercase (only A-Z plus a selected set of Western European special chars).

  10. lower : Converts the string to lowercase (only A-Z plus a selected set of Western European special chars).

  11. alpha : Allows only a-zA-Z characters.

  12. num : Allows only 0-9 characters in the field.

  13. alphanum : Same as "alpha" but allows also "0-9"

  14. alphanum_x : Same as "alphanum" but allows also "_" and "-" chars.

  15. nospace : Removes all occurencies of space characters (chr(32))

  16. md5 : Will convert the inputted value to the md5-hash of it (The JavaScript MD5() function is found in typo3/md5.js)

  17. is_in : Will filter out any character in the input string which is not found in the string entered in the key "is_in" (see below).

  18. password : Will show "*******" in the field after entering the value and moving to another field. Thus passwords can be protected from display in the field. Notice that the value during entering it is visible!

  19. double2 : Converts the input to a floating point with 2 decimal positions, using the "." (period) as the decimal delimited (accepts also "," for the same).

  20. unique : Requires the field to be unique for the whole table. (Evaluated on the server only). NOTICE: When selecting on unique-fields, make sure to select using “AND pid>=0” since the field CAN contain duplicate values in other versions of records (always having PID = -1). This also means that if you are using versioning on a table where the unique-feature is used you cannot set the field to be truely unique in the database either!

  21. uniqueInPid : Requires the field to be unique for the current PID (among other records on the same page). (Evaluated on the server only)

  22. tx_* : User defined form evaluations. See below.

All the above evaluations (unless noted) are done by JavaScript with the functions found in the script t3lib/jsfunc.evalfield.js

"(TCE)"  means the evaluation is done in the TCE on the server. The class used for this is t3lib_TCEmain.

Example:

Setting the field to evaluate the input to a date returned to the database in UNIX-time (seconds)

'eval' => 'date',

Trimming the value for white space before storing in the database (important for varchar fields!)

'eval' => 'trim',

By this configuration the field will be stripped for any space characters, converted to lowercase, only accepted if filled in and on the server the value is required to be unique for all records from this table:

'eval' => 'nospace,lower,unique,required'

User defined form evaluations:

You can supply your own form evaluations in an extension by creating a class with two functions, one which returns the JavaScript code for client side validation called returnFieldJS() and one which does the server side validation called evaluateFieldValue().

The function evaluateFieldValue() has 3 arguments:

  1. $value :The field value to be evaluated.

  2. $is_in : The is_in value of the field configuration from TCA.

  3. &$set : Boolean defining if the value is written to the database or not. Must be passed by reference and changed if needed.

Example:

class.tx_exampleextraevaluations_extraeval1.php:

<?php
class tx_exampleextraevaluations_extraeval1 {
function returnFieldJS() {
return '
return value + " [added by JS]";
';
}
function evaluateFieldValue($value, $is_in, &$set) {
return $value.' [added by PHP]';
}
}

?>

ext_localconf.php

<?php
// here we register "tx_exampleextraevaluations_extraeval1"
$TYPO3_CONF_VARS['SC_OPTIONS']['tce']['formevals']['tx_exampleextraevaluations_extraeval1'] = 'EXT:example_extraevaluations/ class.tx_exampleextraevaluations_extraeval1.php';

?>

Feel free to download the example extension as a T3X file.

 

typo3.org/documentation/document-library/core-documentation/doc_core_api/4.1.0/view/4/2/


TCA多面板

如果您想在TYPO3在后台数据编辑页面多加TAB方法

1.在页面ext_tables.php,加上 ‘dividers2tabs’ => TRUE,
‘dividers2tabs’ => TRUE 加在$tca[‘table_name’][‘ctrl’]这个数组中
2.在页面tca.php, 加上"–div–;tabName”

把这个代码
"types" => array (
        "0" => array("showitem" => "category;;;;1-1-1, sub_category,new_category, headline, description;;;richtext[paste|bold|italic|,ads_type,ads,ads_alt,ads_link")
  ),

修改成
"types" => array (
     "0" => array("showitem" => "–div–;Category,category;;;;1-1-1, sub_category,new_category, headline, description;;;richtext[paste|bold|italic|,–div–;Ads,ads_type,ads,ads_alt,ads_link")
  ),

效果如图:
 

若转载请注明出处: TYPO3中文网
本文地址: http://www.51typo3.cn/typo3/10.html
 


typo3文件操作类

 $file1 = t3lib_div::tempnam(‘file’);
                t3lib_div::writeFile($file1,$sFileContent);
                t3lib_div::upload_copy_move($file1,’../../../../fileadmin/export_user/feusers.’.$export_type);
                unlink($file1);

附xls,csv,export方法:
   /**
     * write the file for export
     *
     * @return    file data
     */
    function writeFile()
    {
        global $LANG;

        $sSelectCol = array();
        $sSelectUsg = array();
        $sFirstLine = array();
        $sFileContent = ”;

        foreach ($this->getColumns() as $sCol){
            if (t3lib_div::GPvar(‘col_’.$sCol)){
                array_push($sSelectCol, $sCol);
                array_push($sFirstLine, ‘col_’.$sCol);
            }
        }

        foreach ($this->getUsergroups() as $sUsg){
            if (t3lib_div::GPvar(‘usg_’.$sUsg[‘uid’])){
                array_push($sSelectUsg, $sUsg[‘uid’]);
            }
        }

        if (count($sSelectCol) > 0 && count($sSelectUsg)>0 && t3lib_div::GPvar(‘export_type’) != ”){

            $aResult = $this->getSqlQueryData(implode(‘,’, $sSelectCol), ‘fe_users’, ‘usergroup=’.implode(‘,’, $sSelectUsg));

            if (!empty($aResult)){

                if (t3lib_div::GPvar(‘export_type’) == ‘csv’){
                    foreach ($sFirstLine as $sF){
                        $colname = ($LANG->getLL($sF)) ? $LANG->getLL($sF) : ‘[‘.$sF.’]’;
                        $sFileContent .= ‘"’.$colname.’";’;
                    }
                    $sFileContent .= "\n";
                    foreach ($aResult as $aR) $sFileContent .= ‘"’.implode(‘";"’, array_values($aR)).’";’."\n";
                    $export_type = ‘csv’;
                } elseif (t3lib_div::GPvar(‘export_type’) == ‘xls’){
                    $sFileContent .=
                        ‘<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">
                            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                            <html>
                                <head>
                                    <meta http-equiv="Content-type" content="text/html;charset=utf-8" />
                                    <style id="Classeur1_16681_Styles">
                                    </style>
                                </head>
                                <body>
                                    <div id="Classeur1_16681" align=center x:publishsource="Excel">
                                        <table x:str border=0 cellpadding=0 cellspacing=0 width=100% style="border-collapse: collapse"><tr>’;

                    foreach ($sFirstLine as $sF){
                        $colname = ($LANG->getLL($sF)) ? $LANG->getLL($sF) : ‘[‘.$sF.’]’;
                        $sFileContent .= ‘<td class=xl2216681 nowrap>’.$colname.'</td>’;
                    }
                    $sFileContent .= ‘</tr>’;
                    foreach ($aResult as $aR) $sFileContent .= ‘<tr><td class=xl2216681 nowrap>’.implode(‘</td><td class=xl2216681 nowrap>’, array_values($aR)).'</td></tr>’;
                    $sFileContent .= ‘</table></div></body></html>’;
                    $export_type = ‘xls’;
                }

                $file1 = t3lib_div::tempnam(‘file’);
                t3lib_div::writeFile($file1,$sFileContent);
                t3lib_div::upload_copy_move($file1,’../../../../fileadmin/export_user/feusers.’.$export_type);
                unlink($file1);

                $output =
                    ‘<table cellpadding="0" cellspcing="0">
                        <tr>
                            <td style="padding-right: 5px;"><img src="moduleicon.gif" alt="Download" /></td>
                            <td style="font-size: 14px; font-weight: bold;">’.$LANG->getLL(‘download_file’).’:</td>
                            <td style="padding-left: 10px;" colspan="2"><a style="text-decoration: underline; font-size: 14px; font-weight: bold;" href="../../../../fileadmin/export_user/feusers.’.$export_type.’" >feusers.’.$export_type.'</a></td>
                        </tr>
                    </table>’;

                return $output;

            } else return ‘<span style="color: red; font-weight: bold; font-size: 14px;">’.$LANG->getLL(‘error’).’: ‘.$LANG->getLL(‘error_nofeuser’).'</span>’;

        } else return ‘<span style="color: red; font-weight: bold; font-size: 14px;">’.$LANG->getLL(‘error’).’: ‘.$LANG->getLL(‘error_nodata’).'</span>’;

    }
 

1 Comment more...

判断前后台用户登录与否

前台:$GLOBALS[‘TSFE’]->loginUser

后台:$GLOBALS[‘BE_USER’]->user

取常量:$GLOBALS[‘TSFE’]->TYPO3_CONF_VARS ($GLOBALS[‘TSFE’]->TYPO3_CONF_VARS[‘SYS’][‘sitename’] 网站名)


typo3读取任意xml文件

http://typo3.org/fileadmin/typo3api-4.2.6/d9/d7e/classlanguage.html#f8731834788a6ef5928b469cbbc579c7

前台:

$lang = t3lib_div::makeInstance(‘language’);
$lang->init($GLOBALS[‘TSFE’]->config[‘config’][‘language’]);
$lang->includeLLFile(‘EXT:ext_demo/locallang_db.xml’);
echo $lang->getLL(‘demo’);

$extLL = $GLOBALS['TSFE']->readLLfile(t3lib_extMgm::extPath('lang')
.'locallang_tca.xml')
$GLOBALS['TSFE']->getLLL('title', $extLL);
$GLOBALS['TSFE']->sL('LLL:dam/locallang_db.xml:tx_dam.title')

后台:

方法一:

$GLOBALS[‘LANG’]->includeLLFile(‘EXT:mm_forum/mod1/locallang.xml’);

$GLOBALS[‘LANG’]->getLL(‘menu.useradmin’)

$LANG->sL()
$LANG->getLL

(直接取出)

方法二:

$arrayname = $GLOBALS[‘LANG’]->readLLfile(‘EXT:mm_forum/mod1/locallang.xml’);

(返回一个数组)

方法三:

t3lib_div::readLLfile(‘EXT:mm_forum/mod1/locallang.xml’, $GLOBALS[‘TSFE’]->config[‘config’][‘language’], ‘utf-8’);


Fatal error: Cannot redeclare class…

Solution:

        if (!class_exists(‘pageModule’)){
            require_once(PATH_site.’fileadmin/scripts/class.page.php’);
        }


New Content Element Wizard didn’t load

– Markup in "crash" and in "normal" doesn’t differ
– It’s not related to Firefox extensions since I could also reproduce it in Firefox’ secure mode without extensions
– It’s not related to the "tabs" feature since it has already be seen with the regular "list"
– it’s not really related to the browser cache since I was able to see it with and without cache
– it’s not related to the wrong XML prolog position in TYPO3 4.2

解决方法:

typo3conf\ext\templavoila\mod1\db_new_content_el.php
Index: mod1/db_new_content_el.php
===================================================================
— mod1/db_new_content_el.php    (revision 30848)
+++ mod1/db_new_content_el.php    (working copy)
@@ -128,6 +128,15 @@
         $this->doc->docType= ‘xhtml_trans’;
         $this->doc->backPath = $BACK_PATH;
         $this->doc->JScode=”;
+
+        if (t3lib_div::compat_version(‘4.3’)) {
+            $pageRenderer = $this->doc->getPageRenderer()->loadPrototype();
+        } elseif (t3lib_div::compat_version(‘4.1’)) {
+            $this->doc->loadJavascriptLib(‘contrib/prototype/prototype.js’);
+        } else {
+            $this->doc->JScodeArray[‘prototypeJS’] = ‘<script type="text/javascript" src="’ . $this->doc->backPath . ‘contrib/prototype/prototype.js"></script>’;
+        }
+
         $this->doc->JScodeLibArray[‘dyntabmenu’] = $this->doc->getDynTabMenuJScode();
         $this->doc->form='<form action="" name="editForm">’;
 
@@ -204,21 +213,23 @@
                 $this->elementWrapper = $this->elementWrapperForTabs;
             }
 
–            // add document inline javascript
+                // add document inline javascript
             $this->doc->JScode = $this->doc->wrapScriptTags(‘
                 function goToalt_doc()    {    //
                     ‘ . $this->onClickEvent . ‘
                 }
 
–                if(top.refreshMenu) {
–                    top.refreshMenu();
–                } else {
–                    top.TYPO3ModuleMenu.refreshMenu();
–                }
+                Event.observe(window, \’load\’, function() {
+                    if(top.refreshMenu) {
+                        top.refreshMenu();
+                    } else {
+                        top.TYPO3ModuleMenu.refreshMenu();
+                    }
 
–                if(top.shortcutFrame) {
–                    top.shortcutFrame.refreshShortcuts();
–                }
+                    if(top.shortcutFrame) {
+                        top.shortcutFrame.refreshShortcuts();
+                    }
+                });
             ‘);
 
                 // Traverse items for the wizard.
 

1 Comment more...

category无限递归分类

function buildTree($pid=0,$content='',$key=0) {
    $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery("*","table_category","parent_id=".$pid);
    while(false != ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))){
        $space = '';
        for($i=0;$i<$key;$i++){$space.="  ";}   //生成空格
        $content .= "";
        $content = $this->buildTree($row['id'],$content,$key+1);
    }
    return $content;
}

 

升级版:(edit)

/**
* buildCategory
* @param $id
* @param $params
* @param $useCache
*/
function buildCategory($id=0,$content=”,$key=0,$local_id = 0) {
$cat_id = -1;
if ($local_id>0) {
$cat_id_array = $this->find_mm_result($local_id,’tx_blog_post_cat_mm’);
}
$res = $GLOBALS[‘TYPO3_DB’]->exec_SELECTquery(“*”,”tx_blog_cat”,”hidden=0 and deleted=0 and pid=”.$GLOBALS[‘Pid’].” and parent_id=”.$id);
while(false != ($row = $GLOBALS[‘TYPO3_DB’]->sql_fetch_assoc($res)))
{
$selected = ”;
if ($row[‘uid’] == $cat_id_array[0]){
$selected = ‘selected=”selected”‘;
}
$space = ”;
for($i=0;$i<$key;$i++){$space.=”&nbsp;&nbsp;”;}
$content .= “<option value='”.$row[‘uid’].”‘ “.$selected.”>”.$space.$row[‘catname’].”</option>”;
$content = $this->buildCategory($row[‘uid’],$content,$key+1,$local_id);
}
return $content;
}

1 Comment more...

Copyright © 1996-2010 Add Lives. All rights reserved.
iDream theme by Templates Next | Powered by WordPress