typo3

FEATURE SPOTLIGHT: LINKHANDLER

PageTSconfig – Make records appear in the link browser

To add a new type of records to the link browser you have to add a few lines of PageTSconfig to the system. Under TCEMAIN.linkHandler you can add new tabs with unique identifiers. By using the TYPO3\CMS\Recordlist\LinkHandler\RecordLinkHandler the link browser knows that the new tab cares about some kind of records. It is possible to add custom LinkHandler since TYPO3 7 LTS (see feature RST). Of course you have to configure the table that stores the records. Other than that you have a few additional options:

TCEMAIN.linkHandler.tx_news {
    handler = TYPO3\CMS\Recordlist\LinkHandler\RecordLinkHandler
    label = News
    configuration {
        table = tx_news_domain_model_news
        storagePid = 164
        hidePageTree = 1
    }
    scanAfter = page
}

 

  • The label can also be a reference to a locallang file (LLL:EXT:...).
  • If hidePageTree is set to 1 the page tree will not be rendered in this link browser tab.
  • If the storagePid is set this page will be rendered when the tab is opened first.
  • If any pageTreeMountPoints are set, those are rendered instead of the normal page tree.
  • The scanAfter (or scanBefore) option defines the order in which handlers are queried when determining the responsible tab for an existing link.
  • The position of the tab can be altered with the option displayAfter (or displayBefore).

The 2nd part of the configuration is concerned with the frontend rendering of the links to the records. So let’s have a look at the TypoScript.

Top 

TypoScript – Tell the Frontend what to do

With the PageTSconfig from above it is now already possible to add links in a RTE. This will create something like <a href="t3://record?identifier=tx_news&amp;uid=2">News</a> in the database. And when this is rendered in the frontend you need to make sure that TYPO3 knows how to resolve the t3://record?identifier=tx_news link. You tell TYPO3 in its favorite language: TypoScript.

config.recordLinks.tx_news {
    typolink {
        parameter = {$myConstants.newsDetailPid}
        additionalParams.data = field:uid
        additionalParams.wrap = &tx_news_pi1[news]=|
        useCacheHash = 1
    }
}
Under config.recordLinks you have to register the same identifier you used in the PageTSconfig. Of course you need to tell TYPO3 on what page the record should be rendered, how to pass the uid and what other parameter need to be added to the URL. You could add 
config.recordLinks.tx_news.forceLink = 1

to force even links to hidden records.

And that is all you have to do.

From: https://usetypo3.com/linkhandler.html


Typo3 Head, Body Tag extend

page.headTag.stdWrap.cObject = COA
page.headTag.stdWrap.cObject{
    5 = TEXT
    5.value = <head>
    10 = TEXT
    10.value(
xxxx
    )
}
page.bodyTagCObject = COA
page.bodyTagCObject{
    5 = TEXT
    5.value = <body>
    10 = TEXT
    10.value(
xxxx
    )
}

 


Typo3 set page title in plugin

 

/**
     * set page title
     * @param $title
     */
    public static function setPageTitle($title){
        GeneralUtility::makeInstance(ObjectManager::class)->get(\TYPO3\CMS\Core\Page\PageRenderer::class)->setTitle($title);
        // For the search
        $GLOBALS['TSFE']->altPageTitle = $title;
        $GLOBALS['TSFE']->indexedDocTitle = $title;
    }

 


Typo3 xlf/xml translation

xlf:

/** @var $languageFactory LocalizationFactory */
        $languageFactory = GeneralUtility::makeInstance(LocalizationFactory::class);
        $LOCAL_LANG = $languageFactory->getParsedData('EXT:sitebase/Resources/Private/Language/locallang.xlf', 'en', 'utf-8');
xml:

public function getTranslate($file, $key, $lang)
    {
        $xml = GeneralUtility::xml2array(file_get_contents($file));
        if (isset($xml['data'][$lang][$key])) {
            return $xml['data'][$lang][$key];
        } else {
            return $xml['data']['default'][$key];
        }
    }

 


Typo3 extend page cache

HOOKS:

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['createHashBase']['currency'] = 'EXT:sitebase/Classes/Hooks/HashHook.php:' . 'Top\\Sitebase\\Hooks\\HashHook->makeHash';







Extbase standalone template

/** @var \TYPO3\CMS\Fluid\View\StandaloneView $fluidTemplate */
        $fluidTemplate = GeneralUtility::makeInstance('TYPO3\CMS\Fluid\View\StandaloneView');
        $fluidTemplate->setLayoutRootPaths(array(GeneralUtility::getFileAbsFileName('EXT:ext_contact_us/Resources/Private/Layouts/')));
        $fluidTemplate->setPartialRootPaths(array(GeneralUtility::getFileAbsFileName('EXT:ext_contact_us/Resources/Private/Partials/')));
        $fluidTemplate->setTemplatePathAndFilename(
            ExtensionManagementUtility::extPath('ext_contact_us') . 'Resources/Private/Templates/ContactUs/Show.html'
        );
        echo $fluidTemplate->render();

Extending Classes in TYPO3

As a TYPO3 extension developer you most certainly will experience situations where you want to extend existing classes, either from the TYPO3 core or from another extension. Fortunately, TYPO3 provides several ways to achieve just that:

Signals, Slots and Hooks

The preferred way of extending existing functionality should always be to use existing Signals and Hooks. Both provide a clearly defined extension interface to developers, which is why it’s pretty safe to use them.

(continue reading…)


extbase Property Mappers

Der neue Property Mapper

Was ist die Aufgabe eines Property Mappers?

Ein Property Mapper hat die Aufgabe, die Daten, die von Formularen an den Webserver gesendet werden in die korrekten Variablentypen zu konvertieren. Alle Daten eines Formulars werden entweder mit Hilfe von POST oder GET (Url) an den Server übertragen, aber diese Transportmethoden können nur mit Arrays und Texten umgehen. Wenn Ihr also in Eurem Formular ein Feld für das Alter einer Person habt und absendet, dann ist für den Server dieses Alter grundsätzlich erstmal ein Text und keine Zahl. Vielleicht habt Ihr aber auch ein Formular auf Eurer Webseite, auf dem Ihr die Beläge Eurer Pizza zusammenstellen könnt (Auswahl per Checkbox). In diesem Fall werden die Daten als Array an der Server übertragen. Solange diese Transportmethoden nicht zwischen Text und Zahl oder auch Array und Objekten unterscheiden können, seid Ihr die Einzigen die wissen von welchem Typ diese Daten sind. Ein Property Mapper kann Euch bei dieser Aufgabe helfen.
(continue reading…)


extbase set storage

$querySettings = $this->productRepository->createQuery()->getQuerySettings();
$querySettings->setStoragePageIds(array(103));
$this->productRepository->setDefaultQuerySettings($querySettings);
1 Comment more...

typo3后台禁止关联删除

TCA Config:

'behaviour' => array(
    'enableCascadingDelete' => false
),

Copyright © 1996-2010 Add Lives. All rights reserved.
iDream theme by Templates Next | Powered by WordPress