TYPO3.CMS 7.6 Schnipsel: Unterschied zwischen den Versionen

Aus Vosp.info
Wechseln zu:Navigation, Suche
(Uri Link erstellen)
(Generell)
Zeile 13: Zeile 13:
  
 
== Generell ==
 
== Generell ==
 
=== Uri Link erstellen ===
 
<source lang=php>
 
$uriBuilder = $this->objectManager->get(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
 
 
$uriBuilder = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder::class);
 
 
# backend uribuilder
 
# $uriBuilder = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
 
 
$uriBuilder->setRequest($this->request);
 
$uriBuilder->setArguments(array(
 
strtolower($this->extensionName) => array(
 
'ncfeuserid' => $user->getUid(),
 
'loginhash' => $randHash,
 
'controller' => 'Nclinklogin',
 
'action' => 'showloginareafromemail',
 
)
 
));
 
$url = $uriBuilder->reset()->uriFor($action, $parameters, $controller);
 
\TYPO3\CMS\Core\Utility\HttpUtility::redirect($url);
 
</source>
 
 
* https://typo3.org/api/typo3cms/class_t_y_p_o3_1_1_c_m_s_1_1_extbase_1_1_mvc_1_1_web_1_1_routing_1_1_uri_builder.html
 
 
 
=== _GET / _POST holen ===
 
=== _GET / _POST holen ===
 
<source lang=php>
 
<source lang=php>

Version vom 19. Dezember 2015, 21:43 Uhr

typoscript

PIDinRootline

[PIDinRootline = 31]
	page.10.variables.INHALT > 
	page.10.variables.INHALT = TEXT
	page.10.variables.INHALT.value = Sie sind auf Seite 31 !!!! und PIDinRootline darf nicht geschachtelt sein!!!!
[global]
  • wichtig die PIDinRootline Condition, darf nicht innner halb von geschweiften {} Klammern geschachtelt stehen

extbase (php)

Generell

_GET / _POST holen

\TYPO3\CMS\Core\Utility\GeneralUtility::_GET();
\TYPO3\CMS\Core\Utility\GeneralUtility::_POST();

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

// im Controller
$confArray = unserialize($GLOBALS["TYPO3_CONF_VARS"]["EXT"]["extConf"][strtolower($this->extensionName)]);

// im Zweifel aber Extensionname (ancextension) angeben!!!!
$confArray = unserialize($GLOBALS["TYPO3_CONF_VARS"]["EXT"]["extConf"][strtolower('ancextension')]);


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();
}

ext_conf_template.txt

vorhandene typen

ext_conf_template.txt

# cat=basic/enable/020;; type=int+; label=LLL:EXT:ancextension/Resources/Private/Language/locallang_be.xml:basic.forgotTimeForDeactivateLogin
forgotTimeForDeactivateLogin =

# cat=basic/enable/030;; type=string; label=LLL:EXT:ancextension/Resources/Private/Language/locallang_be.xml:basic.mailsubject
mailsubject =

# cat=basic/enable/017;; type=options[gleich=0,ungleich=1]; label=LLL:EXT:ancextension/Resources/Private/Language/locallang_be.xml:basic.emailcondition2
emailcondition2 =

eigener typ (als Viewhelper)

ext_conf_template.txt

# cat=basic/enable/050;; type=user[Netzcoop\Ancextension\ViewHelpers\TextArea->render]; label=LLL:EXT:ancextension/Resources/Private/Language/locallang_be.xml:basic.mailtext
mailtext =

Classes/ViewHelpers/TextArea.php

<?php
namespace Netzcoop\Ancextension\ViewHelpers;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extensionmanager\ViewHelpers\Form\TypoScriptConstantsViewHelper;

/**
 * @package jwparking
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
 *
 */
class TextArea {

    /**
     * Tag builder instance
     *
     * @var \TYPO3\CMS\Fluid\Core\ViewHelper\TagBuilder
     */
    protected $tag = NULL;

    /**
     * constructor of this class
     */
    public function __construct() {
        $this->tag = GeneralUtility::makeInstance('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\TagBuilder');
    }

    /**
     * render textarea for extConf
     *
     * @param array $parameter
     * @param TypoScriptConstantsViewHelper $parentObject
     * @return string
     */
    public function render(array $parameter = array(), TypoScriptConstantsViewHelper $parentObject) {
        $this->tag->setTagName('textarea');
        $this->tag->forceClosingTag(TRUE);
        $this->tag->addAttribute('cols', 45);
        $this->tag->addAttribute('rows', 7);
        $this->tag->addAttribute('name', $parameter['fieldName']);
        $this->tag->addAttribute('id', 'em-' . $parameter['fieldName']);
        if ($parameter['fieldValue'] !== NULL) {
            $this->tag->setContent(trim($parameter['fieldValue']));
        }
        return $this->tag->render();
    }

}

fluid

elseif

<f:if condition="{var}!='<ul class=\"navi\"></ul>'">
	<f:then>
		hier ist if
	</f:then>
	<f:else>
		<f:if condition="!{var}">
			<f:then>
				Hier ist else if
			</f:then>
			<f:else>
				Hier ist Else
			</f:else>
		</f:if>						
	</f:else>
</f:if>

allgemein

<f:format.html parseFuncTSPath="lib.parseFunc">{ancitscttnews.bodytext}</f:format.html>