Debugging

Simply add this to your localconf.php file (<root>/typo3conf/localconf.php):


$TYPO3_CONF_VARS['SYS']['devIPmask'] = 'your_ip_address,::1';
$TYPO3_CONF_VARS['SYS']['displayErrors'] = '2';

This should provide you with some meaningful error messages instead of blank pages.

$TYPO3_CONF_VARS[‘SYS’][‘displayErrors’] can have these values: -1, 0, 1, 2 which translates to:

-1 Default setting. With this option, you can override the PHP setting “display_errors”. If devIPmask matches the users IP address the configured “debugExceptionHandler” is used for exceptions, if not “productionExceptionHandler” will be used.
0 Do not display any PHP error messages. Overrides the value of “exceptionalErrors” and sets it to 0 (= no errors are turned into exceptions),the configured “productionExceptionHandler” is used as exception handler
1 Display error messages with the registered error handler, the configured “debugExceptionHandler” is used as exception handler
2 Display errors only if client matches TYPO3_CONF_VARS[SYS][devIPmask]. If devIPmask matches the users IP address the configured “debugExceptionHandler” is used for exceptions, if not “productionExceptionHandler” will be used.

So we chose to display error messages only to certain IP adresses specified in $TYPO3_CONF_VARS[‘SYS’][‘devIPmask’].

Additionally we might want to add these flags to localconf.php file:


$TYPO3_CONF_VARS['SYS']['sqlDebug'] = '1';
$TYPO3_CONF_VARS['BE']['debug'] = '1';
$TYPO3_CONF_VARS['FE']['debug'] = '1';

$TYPO3_CONF_VARS[‘SYS’][‘sqlDebug’] sets sql debugging level. Possible values are:

0 no SQL shown (default)
1 show only failed queries
2 show all queries

$TYPO3_CONF_VARS[‘BE’][‘debug’] is new mode for debugging added with Typo3 4.5:

“A new mode was added to debug the backend with $TYPO3_CONF_VARS[‘BE’][‘debug’] = ‘1’; it disables the login refresh ajax call and instructs the page renderer not to merge the loaded javascript and CSS files, easing debugging with tools like Firebug.”

Source Typo3 Wiki.

$TYPO3_CONF_VARS[‘FE’][‘debug’] should enable frontend debugging.

Additionaly, Typo3 stores frontend and backend errors in sys_log database table. You might want to store these in some separate log file:

$TYPO3_CONF_VARS['SYS']['systemLogLevel'] = '0';
$TYPO3_CONF_VARS['SYS']['systemLog'] = 'error_log';

$TYPO3_CONF_VARS[‘SYS’][‘systemLogLevel’] defines verbosity levels:

0 info
1 notice
2 warning
3 error
4 fatal error

And $TYPO3_CONF_VARS[‘SYS’][‘systemLog’] defines logging method:

file file,<abs-path-to-file>[,<severity>] log to a file
mail mail,<to>[/<from>][,<severity>] send log entries via mail
syslog syslog,<facility>,[,<severity>] use the operating system’s log. Facility may be one of LOCAL0 .. LOCAL7, USER (on Windows USER is the only valid type).
error_log error_log[,,<severity>] use PHP error log

Remember to turn these off in production environment.

Displaying Log off link

To display Log off link, e.g. “Welcome username Log off“:

Setup.TS


lib.welcomeLogOff = COA_INT
lib.welcomeLogOff {
 10 = COA
 10 {
  20 = TEXT
  20.typolink.parameter = 1
  20.typolink.returnLast = url
  20.wrap = <form id="logoutform" action="|" method="post">
  25 = TEXT
  25.wrap = Welcome 
  30 = COA
  30 {
   3 = TEXT
   3.data = TSFE:fe_user|user|username
   4 = TEXT
   4.value =  
   5 = TEXT
   5.value = Log off
   5.wrap = <a href="javascript:{}" onclick="document.getElementById('logoutform').submit(); return false;">|
   10 = TEXT
   10.value = <input type="hidden" name="logintype" value="logout" />
   20 = TEXT
   20.value = <input type="hidden" name="redirect_url" value="" />
   30 = TEXT
   30.value = </form>
  }
 }  
}

or simply:

Setup.TS


lib.logout {
 10 = TEXT
 10 {
  value = Logout
  typolink.parameter.data = TSFE:id
  typolink.additionalParams = &logintype=logout
 }
}

this snippet will create link to current page and add “logintype” variable (&logintype=logout) at the end. If you click on this link Typo3 will sign you out.

Configure Typo3 to use SMTP for mail transport

Append following lines to your localconf.php file (<root>/typo3conf/localconf.php):


$TYPO3_CONF_VARS['MAIL']['transport'] = 'smtp';
$TYPO3_CONF_VARS['MAIL']['transport_smtp_server'] = 'your_smtp_server';
$TYPO3_CONF_VARS['MAIL']['transport_smtp_username'] = 'your_smtp_username';
$TYPO3_CONF_VARS['MAIL']['transport_smtp_password'] = 'your_smtp_password';

or change these using Install tool…

Extend felogin with custom markers

Setup:

Typo3 4.7.7
plugins:
– felogin
– myquizpoll

Setup.TS


plugin.tx_felogin_pi1.customMarkers {
 FEUSER_NUM_OF_POINTS {
  5 >
  5 = LOAD_REGISTER
  5 {
   current_uidvalue >
   current_uidvalue.cObject = CONTENT
   current_uidvalue.cObject {
    table = fe_users
    select {
     pidInList = 5
     recursive = 1
     where.wrap = username = '|'
     where.data = TSFE:fe_user|user|username
     orderBy = name ASC
    }
    renderObj = TEXT
    renderObj.field = uid
   }
   current_totalpoints >
   current_totalpoints.cObject = CONTENT
   current_totalpoints.cObject {
    table = tx_myquizpoll_result
    select {
     selectFields = COALESCE(SUM(tx_myquizpoll_category.tx_myquizbodovi_brbodova),0) AS suma
     leftjoin = tx_myquizpoll_category ON(tx_myquizpoll_category.uid=tx_myquizpoll_result.lastcat)
     where = tx_myquizpoll_result.fe_uid = ###current_uidvalue###
     pidInList = 5
     recursive = 1
     markers {
      current_uidvalue = TEXT
      current_uidvalue.data = register:current_uidvalue
     }
    }
    renderObj = TEXT
    renderObj.field = suma
   }
   current_dbg.cObject = CONTENT
   current_dbg.cObject {
    renderObj = TEXT
    renderObj.data = TSFE:fe_user|user|username
   }
  }
  10 = TEXT
  10.data = register:current_totalpoints
  10.wrap = |
  10.typolink.parameter = 50
 [usergroup=4]
  10.typolink.parameter = 203
 [global]
  10.if.value.data = register:current_totalpoints
  10.if.equals = 0
  15 = TEXT
  15.data = register:current_totalpoints
  15.wrap = |
  15.typolink.parameter = 50
 [usergroup=4]
  15.typolink.parameter = 203
 [global]
  15.if.value.data = register:current_totalpoints
  15.if.equals = 0
  15.if.negate = 1
 }
}

onfocus=”blurLink(this);”

When using HMENU Typo3 has default behaviour to place onfocus=”blurLink(this);” on all links. This somehow tends to break menus on IE.
In order to remove this from menu’s links, noBlur property should be set to 1.


noBlur = 1

Redirect / restrict access

Setup:

Typo3 4.7.7
usergroup that we want to redirect to another page: 6.
pageID for target: 100.

Setup.TS


[usergroup=6]
 config >
 config.additionalHeaders = Location: /index.php?id=100
 page >
 page = PAGE
 page.10 = TEXT
 page.10.value=No Access!
[global]

Create menu from folder

Sometimes we need to create menus or list of items that are not strictly reflecting the current page-structure.
Using “special” property of hierarchical menus (HMENU) we can change the way menu is generated.


special = directory
special.value = 1

Setting HMENUs “special” property to “directory” enables us to create new menu from pages (and their child pages) selected in special.value property (e.g. special.value = 100, 101, 102). If no value is specified, default pid is the current page.


lib.folder_links = HMENU
lib.folder_links{
 special = directory
 special.value = 1 # id of parent item
 1 = TMENU
 1 {
  wrap = <ul class="link">|</ul>
  expAll = 1
  NO.wrapItemAndSub = <li>|</li>
  ACT < .NO
  ACT = 1
  ACT.ATagParams = class="active"
 }
}

special property of hierarchical menus can have these values: “directory” / “list” / “updated” / “browse” / “rootline” / “keywords” / “language” and they are explained in detail on http://wiki.typo3.org/TSref/HMENU.

Breadcrums

Setup.TS


# breadcrums
lib.breadcrums=COA
lib.breadcrums {
10 = HMENU
10 {
 special = rootline
 special.range = 1|-1
# "not in menu pages" should show up in the breadcrumbs menu
 includeNotInMenu = 1
 1 = TMENU
  # no unneccessary scripting.
  1.noBlur = 1
  # Current item should be unlinked
  1.CUR = 1
  1.target = _self
  1.wrap = <div class="breadcrumb-class">|</div>
  1.NO {
   stdWrap.field = title
   ATagTitle.field = nav_title // title
   linkWrap = ||*|  > |*|
  }
  # Current menu item is unlinked
  1.CUR {
   stdWrap.field = title
   linkWrap = ||*|  > |*|
   doNotLinkIt = 1
  }
 }
}

Page meta

Setup.TS


page.meta {
 keywords.field = keywords
 keywords.ifEmpty ( 
  List your keywords....
 )
 description.field = description
 description.ifEmpty ( 
  Enter some page meta description...
 )
 copyright.field = copyright
 copyright.ifEmpty ( 
  Enter some copyright meta description...
 )

This will end up as HTML:

<meta name="keywords" content="List your keywords...." />
<meta name="description" content="Enter some page meta description..." />
<meta name="copyright" content="Enter some copyright meta description..." />

in <head> part of HTML document…

Alternatively this can be achieved using pages headerData:


# Meta Keywords
page.headerData.10 = TEXT
page.headerData.10.insertData=1
page.headerData.10.case=lower
page.headerData.10.wrap =
page.headerData.10.value = List your keywords....
# Meta Description
page.headerData.20 = TEXT
page.headerData.20.insertData=1
page.headerData.20.wrap =
page.headerData.20.value = Enter some page meta description...
# Meta Copyright
page.headerData.30 = TEXT
page.headerData.30.insertData=1
page.headerData.30.wrap =
page.headerData.30.value = Enter some copyright meta description...