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...

TYPO3 – create mobile version of website (templavoila)

First of all we need to add new rendering option to templavoila plugin:

Setup.TS


TCEFORM.tx_templavoila_tmplobj.rendertype.addItems.mobile = Mobile version

Afterwards, create a new sub-templates for desired pages (admin backend).

We can detect users agent with Typo3 built-in conditions:


[useragent= agent]

 
Check if useragent is mobile:


[useragent = *iPhone*]  ||  [useragent = *iPod*]  ||  [useragent = *iPad*]  ||  [useragent = *Android*]  ||  [useragent = *OperaMini*]  ||  [useragent = *BlackBerry*]

Setup.TS


[useragent = *iPhone*]  ||  [useragent = *iPod*]  ||  [useragent = *iPad*]  ||  [useragent = *Android*]  ||  [useragent = *OperaMini*]  ||  [useragent = *BlackBerry*]
# if it's mobile, set childtemplate to mobile
 plugin.tx_templavoila_pi1.childTemplate = mobile
 page = PAGE
 page >
 page = PAGE
 page.10 = USER
 page.10.userFunc = tx_templavoila_pi1->main_page
#name of child template
 page.10.childTemplate = mobile
#change doctype and encoding
 page.config >
 page.config {
#output will be utf-8
  renderCharset = utf-8
#doctype for mobile devices will be XHTML MP 1.0
   doctype (
   <?xml version="1.0" encoding="utf-8"?>
   <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd" >
  )
 }
[else]
 page = PAGE
 page.10 = USER
 page.10.userFunc = tx_templavoila_pi1->main_page
[END]

while you’re at it you might want to change your menu layout to include different navigation. This will create menu from pages that have pageID 199 as their parent:

Setup.TS


[useragent = *iPhone*] || [useragent = *iPod*] || [useragent = *iPad*] || [useragent = *Android*] || [useragent = *OperaMini*] || [useragent = *BlackBerry*]
 lib.mainMenu = HMENU
 lib.mainMenu{
  special = directory
  special.value = 199 
  1 = TMENU
  1 {
   wrap = <ul class="menu">|</ul>
   expAll = 1
   NO.wrapItemAndSub = <li><div class="someclass">|</div></li>
   ACT < .NO
   ACT = 1
   ACT.ATagParams = class="active"
  }
 }
[global]

and you should change template files of various plugins…