Typo3

Passing Typoscript Values to PHP Code

How to get Typoscript Setup parameters into an extension's PHP code, or how to send Typoscript parameters to PHP code, or passing parameters to PHP code.

Here is an example of Typoscript in the 'Setup:' portion of the 'Template' back-end module for a page that implements the pillarstore extension plugin:

plugin.tx_pillarstore_pi1{
  approvalCode = 0
  orderFormPID = 100
  orderStoragePID = 200
  addEditUserAccountPID = 300
  contactUsPID = 400
  memberGroup = 10
  emailFromName = PillarLogic, LLC
  emailFromAddress = email@mycompany.com
  paymentAddress1 = My Company Name
  paymentAddress2 = 123 Sesame St.
  paymentAddress3 = Anytown, WI 55555
}

And here is the PHP code in the pillarstore extension plugin file class.tx_pillarstore_pi1.php that gets the values from the Typoscript Setup:

// TYPOSCRIPT SETUP PARAMETERS
// These values are passed in from the Typoscript Setup
// and should not be changed during script execution.     
$approvalCode = strval($conf['approvalCode']);
$orderFormPID = $conf['orderFormPID'];
$orderStoragePID = $conf['orderStoragePID'];
$addEditUserAccountPID = $conf['addEditUserAccountPID'];
$contactUsPID = $conf['contactUsPID'];
$memberGroup = $conf['memberGroup'];
$emailFromName = $conf['emailFromName'];
$emailFromAddress = $conf['emailFromAddress'];
$paymentAddress1 = $conf['paymentAddress1'];
$paymentAddress2 = $conf['paymentAddress2'];
$paymentAddress3 = $conf['paymentAddress3'];
// END OF: TYPOSCRIPT SETUP PARAMETERS

Steps for Moving a Typo3 Web Site to a New Location

This is assuming use of the WEC starter package.

web server:

  1. turn off php safe mode in Plesk/Domains/[domain]/Web Hosting Settings/Php Support (clear the checkbox)
  2. turn off safe mode in /etc/php.ini
  3. Restart web server

local copy:

  1. delete all the files that begin with temp_ in  /typo3conf

server copy:

  1. upload files
  2. change the permissions recursively for /fileadmin, /typo3conf, /typo3temp, /uploads, and index.php to chmod 777.
  3. setup .htaccess
  4. set db in install tool
  5. set page not found in install tool
  6. set page not available in install tool
  7. set cookie domain localconfig.php with install tool
  8. set Site URL in wec config module in back-end

.htaccess file example (the last two lines are for strict https):

RewriteEngine On

RewriteBase /
RewriteRule ^(typo3|t3lib|tslib|fileadmin|typo3conf|typo3temp|uploads|favicon\.ico)/ - [L]
RewriteRule ^/typo3$ typo3/index_re.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L]

RewriteCond %{HTTPS} !=on [NC]
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

Front End Indexing Explained

The Typo3 front-end indexing can be seen in the back-end with the 'Info' module.  Select the Info module then click on a page to see its indexing. There some select boxes on the right, and the top one needs to be set to 'Indexed Search.' To see as much as possible at one time, click on a Web site root page and select the 'Words and Content' view & 'Infinite'.

To re-index all pages immediately, clear the indexing by selecting the 'Technical Details' view and clicking the trash-can icon next to 'phash'. To re-index, LOG OUT OF THE BACK-END and visit each page in the front-end that needs to be indexed. They will index immediately.

Individual pages can also be re-indexed, first by selecting the page, then clicking the trash-can icon next to that particular section, then LOGGING OUT OF THE BACK-END and visiting those particular pages in the front-end. They will index immediately.

Otherwise there is a minimum wait time before a page will be automatically re-indexed, which is specified in the settings of the 'Indexed Search Engine' extension plugin. The settings can be changed by going into the 'Extension Manager' back-end module and selecting the plugin.

mm_forum Extension Plugin Date Format

There are four places in my usage of the mm_forum extension where I wanted to change the date format: The 'last ten topics' date, the 'last edited' date, the 'registered since' date, and the 'last post' date. I found four things that I needed to modify:

  • I had originally added the dateFormat in the Typoscript: dateFormat = m/d/Y [H:i] ...but it displayed exactly that - 'm/d/Y [H:i]' instead of a date and time. I dug into the code and found out it is using strftime() so when I changed the Typoscript to: dateFormat = %m/%d/%Y [%H:%M] ... now it works, but that only changes the date formatting for the 'last post' dates. The other date formats are hard-coded in PHP.
  • Changes I made to hard-coded date formats (replaced d.m.Y with m/d/Y):
    • mm_forum/pi1/class.tx_mmforum_postfunctions.php, line 548
      • original: '###DATE###'  => date(' d.m.Y ', $row['edit_time']),
      • modified: '###DATE###'  => date(' m/d/Y ', $row['edit_time']),
    • mm_forum/pi1/class.tx_mmforum_pi1.php, line 4602
      • original: $content .= $this->cObj->wrap($this->pi_getLL('user.regSince') . ': ' . date('d.m.Y', $userData['crdate']) . '<br />' . $this->pi_getLL('user.posts') . ': ' . $userData['tx_mmforum_posts'], $this->conf['list_posts.']['userinfo_content_wrap']);
      • modified: $content .= $this->cObj->wrap($this->pi_getLL('user.regSince') . ': ' . date('m/d/Y', $userData['crdate']) . '<br />' . $this->pi_getLL('user.posts') . ': ' . $userData['tx_mmforum_posts'], $this->conf['list_posts.']['userinfo_content_wrap']);
    • mm_forum/res/ts/tx_mmforum_pi1.ts, line 337
      • original: crdate_stdWrap.date = d.m.Y
      • modified: crdate_stdWrap.date = m/d/Y
 
Add To Favorites