TYPO3.CMS 7.6 Schnipsel: Unterschied zwischen den Versionen
Aus Vosp.info
F (Diskussion | Beiträge) (→Domain) |
F (Diskussion | Beiträge) (→Generell) |
||
Zeile 3: | Zeile 3: | ||
== Generell == | == Generell == | ||
+ | |||
+ | === hole Objektmanager um Klassen bzw Objekte zu laden === | ||
<source lang=php> | <source lang=php> | ||
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager'); | $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager'); | ||
Zeile 8: | Zeile 10: | ||
</source> | </source> | ||
+ | ===hole Extension Konfiguration aus dem Backend === | ||
+ | |||
+ | Formularfelder die vorher in ext_conf_template.txt definiert und im Backend unter Erweiterungsmanager bei der Extension eingestellt wurden | ||
+ | |||
+ | '''ext_conf_template.txt''' | ||
+ | <source lang=php> | ||
+ | # cat=basic/enable/010; type=int; label=LLL:EXT:ancextension/Resources/Private/Language/locallang_be.xml:basic.varInt | ||
+ | varInt = | ||
+ | |||
+ | # cat=basic/enable/020; type=string; label=LLL:EXT:ancextension/Resources/Private/Language/locallang_be.xml:basic.varString | ||
+ | varString = default wert | ||
+ | </source> | ||
+ | '''werte holen''' | ||
+ | <source lang=php> | ||
+ | $confArray = unserialize($GLOBALS["TYPO3_CONF_VARS"]["EXT"]["extConf"][strtolower($this->extensionName)]); | ||
+ | echo $confArray['varString']; | ||
+ | </source> | ||
=== logout / login === | === logout / login === | ||
<source lang=php> | <source lang=php> |
Version vom 18. Dezember 2015, 16:33 Uhr
Inhaltsverzeichnis
extbase (php)
Generell
hole Objektmanager um Klassen bzw Objekte zu laden
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager');
$ncmail = $objectManager->get('Netzcoop\Extension\Services\Ncmail');
hole Extension Konfiguration aus dem Backend
Formularfelder die vorher in ext_conf_template.txt definiert und im Backend unter Erweiterungsmanager bei der Extension eingestellt wurden
ext_conf_template.txt
# cat=basic/enable/010; type=int; label=LLL:EXT:ancextension/Resources/Private/Language/locallang_be.xml:basic.varInt
varInt =
# cat=basic/enable/020; type=string; label=LLL:EXT:ancextension/Resources/Private/Language/locallang_be.xml:basic.varString
varString = default wert
werte holen
$confArray = unserialize($GLOBALS["TYPO3_CONF_VARS"]["EXT"]["extConf"][strtolower($this->extensionName)]);
echo $confArray['varString'];
logout / login
protected function login($ncfeuserid) {
$user = $this->userRepository->findByUid($ncfeuserid);
$GLOBALS['TSFE']->fe_user->createUserSession($user->_getProperties());
$GLOBALS["TSFE"]->fe_user->user = $GLOBALS["TSFE"]->fe_user->fetchUserSession();
// es wird empfohlen jetzt zu redirect'en
}
protected function logout() {
$GLOBALS['TSFE']->fe_user->logoff();
}
Controller
Url/Link erstellen
$uriBuilder = $this->controllerContext->getUriBuilder();
$uriBuilder->reset();
$uriBuilder->setArguments(array(
strtolower($this->extensionName) => array(
'param1' => $user->getUid(),
'param2' => 'test',
)
));
$uri = $uriBuilder->build();
\TYPO3\CMS\Core\Utility\HttpUtility::redirect($uri, \TYPO3\CMS\Core\Utility\HttpUtility::HTTP_STATUS_303);
Domain
Database
direktes sql
// prepare_SELECTquery ($select_fields, $from_table, $where_clause, $groupBy= '', $orderBy= '', $limit= '', array $input_parameters=array())
$statement = $GLOBALS['TYPO3_DB']->prepare_SELECTquery(
'*' // $select_fields
, 'tab1, tab1_mm as mm' // $from_table
, 'tt_news.uid = mm.uid_local ' // $where_clause
. 'AND tt_news.pid = :store_page_id '
. $ncsearchwhere.$between
, '' // $groupBy
, 'crdate DESC' // $orderBy
, '' // $limit
);
$statement->bindValues(array(
':store_page_id' => $store_page_id
));
if ($statement) {
$statement->execute();
$return = $statement->fetchAll();
$statement->free();
}
fluid
<f:format.html parseFuncTSPath="lib.parseFunc">{ancitscttnews.bodytext}</f:format.html>