Showing posts with label TYPO3. Show all posts
Showing posts with label TYPO3. Show all posts

Friday, 2 January 2015

tt_news: Modify query to database

tt_news is an extension of TYPO3 designed to publish news in our website. It's a very popular extension and it allows publish and manage news about our company, association, etc. You can find extension manual here.

Suppose that we have our own extension with our own plugins and we want to indicate that in the news list we only want news with ID greater than 100... So we should use a hook that is prepared for the extension in order to modify the database query.

In this example we used TYPO3 4.4.4 and tt_news 3.0.1. Files to modify are:
ext_localconf.php

if (TYPO3_MODE == 'FE')  { require_once(t3lib_extMgm::extPath('user_t3_test').'user_t3_test_selectHook.php'); }
$TYPO3_CONF_VARS['EXTCONF']['tt_news']['selectConfHook'][] = 'user_t3_test_selectHook';


user_t3_test_selectHook.php

class user_t3_test_selectHook {
public function processSelectConfHook(&$parentObject, $selectConf) {
$selectConf['where'] .= ' AND uid > 100 ';
return $selectConf;
}


I hope you find it useful! Regards!

Thursday, 1 January 2015

Overwrite title tag with TypoScript

TYPO3 is a powerful CMS that uses its own configuration language called TypoScript. This article does not explain what or how to configure TYPO3. In this case only show you how to override the title tag of a page using TypoScript. To develop this example we used a quite old version of TYPO3: 4.2.14 but this solution is also valid for newer versions. Suppose we want new title "Test", then the TypoScript of our template should be:
config.noPageTitle = 2
page = PAGE
page.headerData.10 = TEXT
page.headerData.10.wrap = <title>Test</title>
In the first line we say that we don't want to print the default title. More info here. In the other 3 lines we change the page header adding our title. I hope you find it useful! Regards!

Wednesday, 4 June 2014

felogin: actions to do after login

Sometimes inside a TYPO3 website after install and config felogin, we would like to do some actions everytime that user would acces to website. To do that, we can use an extension hook. In this example we use TYPO3 4.5.32 and 1.3.1 felogin.

Inside ext_localconf.php of our extension:

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['felogin']['login_confirmed'][] = 'EXT:test_extension/hooks/class.feloginhook.php:test_extension_hooksHandler->onLogin';

Inside class.feloginhook.php:

class test_extension_hooksHandler { public function onLogin() { // Actions to do here... Insert in a database, in a log... redirections... } }

Regards!

Thursday, 10 April 2014

HMENU: add class to li tag

Hello,

Today I was creating a new HMENU with Typoscript and I have found a problem. I had this HMENU already configured:

temp.links = HMENU temp.links.special = list temp.links.special.value = 1,2,3,4,5 temp.links { 1 = TMENU 1 { wrap = <ul>|</ul> NO.linkWrap = <li>|</li> } }

Then I saw that I wanted to add a class in the last li tag. The solution is:

temp.links = HMENU temp.links.special = list temp.links.special.value = 1,2,3,4,5 temp.links { 1 = TMENU 1 { wrap = <ul>|</ul> NO.linkWrap = <li>|</li>|*||*|<li class="specialClasss">|</li> } }

Best regards!

Monday, 31 March 2014

TYPO3: Use session variables

Hello,

In TYPO3 is very useful to manage session variables in frontend plugins:
  • Get 'test' variable: $test = $GLOBALS['TSFE']->fe_user->getKey('ses', 'test');
  • Save  'test' variable: $GLOBALS['TSFE']->fe_user->setKey('ses', 'test', $test); $GLOBALS['TSFE']->fe_user->storeSessionData();
Regards!