Skip to content

Instantly share code, notes, and snippets.

View einpraegsam's full-sized avatar
💭
Ready to find solutions

Alexander Kellner einpraegsam

💭
Ready to find solutions
View GitHub Profile
@einpraegsam
einpraegsam / Introduction.txt
Last active January 10, 2021 16:15
Auto-release new TYPO3 extensions from github to TER (TYPO3 Extension Repository) when they are tagged via REST API
Github actions gives you the possibility to run some code after a special trigger (e.g. a push into a repo) is recognized.
This can be used for running tests or - in our case - to deploy the software to TYPO3 TER when a new tag is pushed.
1) First of all, you should login on extensions.typo3.org and create some access token (API Token) to use the new REST API of typo3.org
to publish your extensions (see https://github.com/TYPO3/tailor#prerequisites for some more help on this).
2) After that you can add three secret tokens in your github repository
(see https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-an-environment for some more details):
TYPO3_API_USERNAME (your username for FE-login on typo3.org)
TYPO3_API_PASSWORD (your password for FE-login on typo3.org)
@einpraegsam
einpraegsam / AdditionalConfiguration.php
Created December 17, 2020 08:50
CURL requests in TYPO3 with invalid SSL certificate
$GLOBALS['TYPO3_CONF_VARS']['HTTP']['verify'] = false;
@einpraegsam
einpraegsam / NotAuthorized.php
Last active October 23, 2024 20:07
Individual 403 and 404 handling in TYPO3 9 and 10. Show a 404 page but keep wrong URL. In case of a missing frontend login, redirect to login page and redirect back after login.
<?php
declare(strict_types=1);
namespace Vendor\Sitepackage\PageHandler;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Error\PageErrorHandler\PageErrorHandlerInterface;
use TYPO3\CMS\Core\Http\RedirectResponse;
use TYPO3\CMS\Core\Http\Uri;
use TYPO3\CMS\Core\Site\Entity\Site;
@einpraegsam
einpraegsam / SiteFactory.php
Last active June 10, 2022 13:42
What can you do with SiteConfiguration in TYPO3 and how to get a site object from anywhere?
<?php
declare(strict_types=1);
namespace Vendor\Extension\Factory;
use GuzzleHttp\Psr7\Uri;
use TYPO3\CMS\Core\Exception\SiteNotFoundException;
use TYPO3\CMS\Core\Http\Request;
use TYPO3\CMS\Core\Http\ServerRequest;
use TYPO3\CMS\Core\Routing\SiteMatcher;
use TYPO3\CMS\Core\Site\Entity\Site;
@einpraegsam
einpraegsam / LanguageRedirect.php
Last active December 14, 2021 15:17
TYPO3: Simply redirect a visitor to secondary language if browser does not support default language using PSR-15 Middleware
<?php
declare(strict_types=1);
namespace In2code\In2template\Middleware;
use CodeZero\BrowserLocale\BrowserLocale;
use CodeZero\BrowserLocale\Filters\LanguageFilter;
use In2code\In2template\Utility\ObjectUtility;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
@einpraegsam
einpraegsam / AbstractJsonLdSchemaViewHelper.php
Created April 11, 2020 17:39
JSON LD ViewHelpers to create information for Google & Co. out of pages or other records. Files in this examples in EXT:in2template/Classes/ViewHelpers/JsonLdSchema/
<?php
namespace In2code\In2template\ViewHelpers\JsonLdSchema;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* Class AbstractJsonLdSchemaViewHelper
*/
abstract class AbstractJsonLdSchemaViewHelper extends AbstractViewHelper
{
@einpraegsam
einpraegsam / MysqlXml.txt
Created October 2, 2019 07:25
MySQL: Read and write values from XML (e.g. TYPO3 FlexForm)
# Read: Show real path in sys_file_storage
select name, uid, ExtractValue(configuration, '//T3FlexForms/data/sheet[@index="sDEF"]/language/field[@index="basePath"]/value') path from sys_file_storage where uid > 0
# Write: Set a new value (in this case a detail pid) in FlexForm of a tt_news plugin
UPDATE tt_content SET pi_flexform = UpdateXML(pi_flexform, '//T3FlexForms/data/sheet[@index="s_misc"]/language/field[@index="PIDitemDisplay"]/value', CONCAT('<value index="vDEF">', 123, '</value>' )) WHERE uid=11107
@einpraegsam
einpraegsam / 10Dinge.txt
Created September 27, 2019 07:26
10 Anzeichen dass du vielleicht zu viel für deine TYPO3 Extension bezahlt hast lieber Kunde...
Hier findest du 10 Anzeichen dafür, dass du vielleicht zu viel für
deine TYPO3 Extension bezahlt hast lieber Kunde:
1. Das Icon der für dich entwickelten Extension ist das schwarz/graue TYPO3-Zeichen.
Datensätze in der Listenansicht haben komischerweise alle ein E-Symbol
und das obowhl die Extension gar nicht mit E anfängt.
2. Der Status der Extension steht schon seit über einem Jahr
auf 0.0.0 alpha.
@einpraegsam
einpraegsam / FlexformStudyfinderList.xml
Last active June 30, 2023 14:59
Overwrite a FlexForm from any Extension with your FlexForm in TYPO3
<T3DataStructure>
<meta>
<langDisable>1</langDisable>
</meta>
<sheets>
<main>
<ROOT>
<TCEforms>
<sheetTitle>LLL:EXT:in2studyfinder/Resources/Private/Language/locallang_db.xlf:listView</sheetTitle>
</TCEforms>
@einpraegsam
einpraegsam / GeneralUtility.php
Created February 6, 2019 12:30
Alternative GeneralUtility::xml2array() without 10MB restriction from libxml - for import and export . Quick and dirty hack, exactly like to the original one in TYPO3.
<?php
namespace TYPO3\CMS\Core\Utility;
use GuzzleHttp\Exception\RequestException;
use TYPO3\CMS\Core\Core\ApplicationContext;
use TYPO3\CMS\Core\Core\ClassLoadingInformation;
use TYPO3\CMS\Core\Crypto\Random;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Http\RequestFactory;
use TYPO3\CMS\Core\Service\OpcodeCacheService;