SysFolder Icons with TYPO3 Icon-API - typo3

Till TYPO3 CMS 6.2 i've been using the following code in extTables.php to provide sysfolder icons:
$TCA['pages']['columns']['module']['config']['items'][] = array('Templates', 'templates', '/fileadmin/icons/application_side_list.png');
\TYPO3\CMS\Backend\Sprite\SpriteManager::addTcaTypeIcon('pages', 'contains-templates', '/fileadmin/icons/application_side_list.png');
As since 7.6 the code is obsolete and icons are provided by the Icon-API. Am I right? So my question is, if it's still possible to provide sysfolder icons to the backend using BitmapIconProvider, SvgIconProvider or the FontawesomeIconProvider?

Yes, this should work using the IconRegistry core class:
ext_localconf.php:
if (TYPO3_MODE === 'BE') {
/** #var \TYPO3\CMS\Core\Imaging\IconRegistry $iconRegistry */
$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);
$iconRegistry->registerIcon(
'apps-pagetree-folder-contains-templates',
\TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class,
['source' => 'EXT:myext/Resources/Public/Icons/application_side_list.png']
);
}
ext_tables.php:
if (TYPO3_MODE === 'BE') {
$GLOBALS['TCA']['pages']['columns']['module']['config']['items'][] = [
0 => 'Templates',
1 => 'templates',
2 => 'apps-pagetree-folder-contains-templates'
];
}

The TYPO3 extension must be modified to fit the needs of TYPO3 7.5 and higher. Replace myextkey by the extension key of your extension.
ext_localconf.php:
if (TYPO3_MODE == 'BE') {
$pageType = 'myext10'; // a maximum of 10 characters
$icons = array(
'apps-pagetree-folder-contains-' . $pageType => 'apps-pagetree-folder-contains-myextkey.svg'
);
/** #var \TYPO3\CMS\Core\Imaging\IconRegistry $iconRegistry */
$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);
foreach ($icons as $identifier => $filename) {
$iconRegistry->registerIcon(
$identifier,
$iconRegistry->detectIconProvider($filename),
array('source' => 'EXT:' . $_EXTKEY . '/Resources/Public/Icons/' . $filename)
);
}
}
Configuration/TCA/Overrides/pages.php:
<?php
if (!defined ('TYPO3_MODE')) {
die ('Access denied.');
}
// add folder icon
$pageType = 'myext10'; // a maximum of 10 characters
$iconReference = 'apps-pagetree-folder-contains-' . $pageType;
$addToModuleSelection = TRUE;
foreach ($GLOBALS['TCA']['pages']['columns']['module']['config']['items'] as $item) {
if ($item['1'] == $pageType) {
$addToModuleSelection = false;
break;
}
}
if ($addToModuleSelection) {
$GLOBALS['TCA']['pages']['ctrl']['typeicon_classes']['contains-' . $pageType] = $iconReference;
$GLOBALS['TCA']['pages']['columns']['module']['config']['items'][] = array(
0 => 'LLL:EXT:myextkey/locallang.xml:pageModule.plugin',
1 => $pageType,
2 => $iconReference
);
}
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerPageTSConfigFile(
$pageType,
'Configuration/TSconfig/Page/folder_tables.txt',
'EXT:myextkey :: Restrict pages to myextkey records'
);
locallang.xml:
<label index="pageModule.plugin">My Extension: Table names of my extension</label>
Resources/Public/Icons/apps-pagetree-folder-contains-myextkey.svg:
vector graphic image file for your extension tables
see https://github.com/TYPO3/TYPO3.Icons for working example SVG icons.
Configuration/TSconfig/Page/folder_tables.txt:
Insert the table names of your extension.
mod.web_list.allowedNewTables = tx_myextkey_tablename1, tx_myextkey_tablename2, tx_myextkey_tablename3

Related

TYPO3 Render FLUID Template in Backend

I have an extbase extension with this TCA:
$GLOBALS['TCA']['tt_content']['types']['list']['previewRenderer']['items_item']
= \Vendor\Name\Backend\Preview\PreviewRenderer::class;
and this tsconfig:
mod.web_layout.tt_content.preview.list.items_item = EXT:EXT/Resources/Private/Templates/Preview/Items.html
Everything works well if i write the complete Code in this template file. But if i change it and use Partials like this:
<f:render arguments="{_all}" partial="Preview/List"/>
I only get the following error:
Error while rendering FluidTemplate preview using /typo3conf/ext/EXT/Resources/Private/Templates/Preview/Items.html The Fluid template files "" could not be loaded.
How can i set the Partial and Layout path?
Ive tried ist with module via typoscript but it doesnt work.
It depends on what your PreviewRender is doing.
The StandardContentPreviewRenderer supports only a template-file, no layouts, no partials. It's using a FluidStandaloneView and only setting setTemplatePathAndFilename() without setting paths for other parts of the template (renderContentElementPreviewFromFluidTemplate()):
protected function ‪renderContentElementPreviewFromFluidTemplate(array $row): ?string
{
$tsConfig = BackendUtility::getPagesTSconfig($row['pid'])['mod.']['web_layout.']['tt_content.']['preview.'] ?? [];
$fluidTemplateFile = '';
if ($row['CType'] === 'list' && !empty($row['list_type'])
&& !empty($tsConfig['list.'][$row['list_type']])
) {
$fluidTemplateFile = $tsConfig['list.'][$row['list_type']];
} elseif (!empty($tsConfig[$row['CType']])) {
$fluidTemplateFile = $tsConfig[$row['CType']];
}
if ($fluidTemplateFile) {
$fluidTemplateFile = GeneralUtility::getFileAbsFileName($fluidTemplateFile);
if ($fluidTemplateFile) {
try {
$view = GeneralUtility::makeInstance(StandaloneView::class);
$view->setTemplatePathAndFilename($fluidTemplateFile);
$view->assignMultiple($row);
if (!empty($row['pi_flexform'])) {
$flexFormService = GeneralUtility::makeInstance(FlexFormService::class);
$view->assign('pi_flexform_transformed', $flexFormService->convertFlexFormContentToArray($row['pi_flexform']));
}
return $view->render();
} catch (\‪Exception $e) {
$this->logger->warning('The backend preview for content element {uid} can not be rendered using the Fluid template file "{file}"', [
'uid' => $row['uid'],
'file' => $fluidTemplateFile,
'exception' => $e,
]);
if (‪$GLOBALS['TYPO3_CONF_VARS']['BE']['debug'] && $this->‪getBackendUser()->isAdmin()) {
$view = GeneralUtility::makeInstance(StandaloneView::class);
$view->assign('error', [
'message' => str_replace(‪Environment::getProjectPath(), '', $e->getMessage()),
'title' => 'Error while rendering FluidTemplate preview using ' . str_replace(‪Environment::getProjectPath(), '', $fluidTemplateFile),
]);
$view->setTemplateSource('<f:be.infobox title="{error.title}" state="2">{error.message}</f:be.infobox>');
return $view->render();
}
}
}
}
return null;
}
If you want more advanced features in your preview, you have to extend/override this method.
Update:
StandaloneView extends TYPO3\CMS\Fluid\View\AbstractTemplateView, so you have also those setters:
setTemplate($templateName)
setTemplatePathAndFilename($templatePathAndFilename)
setTemplateRootPaths(array $templateRootPaths)
setPartialRootPaths(array $partialRootPaths)
setLayoutRootPaths(array $layoutRootPaths)
So setting paths for partials in your ‪renderContentElementPreviewFromFluidTemplate() should solve it:
$view->setPartialRootPaths([
\TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:extensionfolder/Resources/Private/Partials'),
]);

TYPO3 I got an error by list after the installation of my own plugin

My TYPO3 version is 10.4.21 and I use extensions (Fluid styled content, sitepackage, Bootstrap, pizpalue and my own plugin which I made).
I created a plugin which names New Flipbox, because I have to make a new content element with a function of flipbox for my project work. But I have an error.
If I click a list button on the menu on the left side, an error occurred:
Oops, an error occurred! An exception occurred while executing 'SELECT
uid FROM tx_myextensionkey_domain_model_newflipbox WHERE
(tx_myextensionkey_domain_model_newflipbox.pid = ?) AND
((tx_myextensionkey_domain_model_newflipbox.deleted = 0) AND
((tx_myextensionkey_domain_model_newflipbox.t3ver_wsid = 0) AND
(tx_myextensionkey_domain_model_newflipbox.t3ver_oid = 0)))
LIMIT 1' with params [1]: SQLSTATE[42S02]: Base table or view not
found: 1146 Table
'd037b84f.tx_rsnmizukiflipbox_domain_model_newflipbox' doesn't exist
How can I fix it?
For now, I've written down these:
in /typo3conf/ext/myextension/Configuration/TCA/Overrides/tt_content.php:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(
array(
'My Flipbox',
'rsnflipbox',
'EXT:core/Resources/Public/Icons/T3Icons/content/content-carousel-image.svg'
),
'CType',
'myextensionkey'
);
// Configure the default backend fields for the content element
$GLOBALS['TCA']['tt_content']['types']['flipbox_contentelement'] = [
'showitem' => '
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
--palette--;;general,
header; Internal title (not displayed),
bodytext;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:bodytext_formlabel,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
--palette--;;hidden,
--palette--;;access,
',
'columnsOverrides' => [
'bodytext' => [
'config' => [
'enableRichtext' => true,
'richtextConfiguration' => 'default',
],
],
],
];
in /typo3conf/ext/myextension/ext_location.php
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(
'mod {
wizards.newContentElement.wizardItems.plugins {
elements {
newflipbox {
iconIdentifier = content-dashboard
title = LLL:EXT:myextensionkey/Resources/Private/Language/locallang_db.xlf:tx_myextensionkey_newflipbox.name
description = LLL:EXT:myextensionkey/Resources/Private/Language/locallang_db.xlf:tx_myextensionkey_newflipbox.description
tt_content_defValues {
CType = list
list_type = key_newflipbox
}
}
}
show = *
}
}'
);
// wizards bei Plugin
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(
'mod {
wizards.newContentElement.wizardItems.interactive {
elements {
newflipbox {
iconIdentifier = content-dashboard
title = LLL:EXT:myextensionkey/Resources/Private/Language/locallang_db.xlf:tx_myextensionkey_newflipbox.name
description = LLL:EXT:myextensionkey/Resources/Private/Language/locallang_db.xlf:tx_myextensionkey_newflipbox.description
tt_content_defValues {
CType = list
list_type = key_newflipbox
}
}
}
show = *
}
}'
);
$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);
$iconRegistry->registerIcon(
'myextensionkey-plugin-newflipbox',
\TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
['source' => 'EXT:myextensionkey/Resources/Public/Icons/user_plugin_newflipbox.svg']
);
});
in /typo3conf/ext/myextension/Configuration/TypoScript/setup.typoscript
lib.contentElement {
templateRootPaths.200 = EXT:myextensionkey/Resources/Private/Templates/
}
lib.contentElement {
partialRootPaths.200 = EXT:myextensionkey/Resources/Private/Partials/
}
lib.contentElement {
layoutRootPaths.200 = EXT:myextensionkey/Resources/Private/Layouts/
}
tt_content {
flipbox_contentelement =< lib.contentElement
flipbox_contentelement {
templateName = NewContentElement
}
}
I saw a website of TYPO3(https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/ContentElements/AddingYourOwnContentElements.html) to create a element content, but I can't go on because of some errors.
What should I do now? I hope someone can help me.
Thank you.
The error message clearly states that the table tx_rsnmizukiflipbox_domain_model_newflipbox is missing. So you should check if you have added ext_tables.sql with the necessary database fields and then you should go to the install tool and do a database compare to create the missing table.

CodeIgniter Suddenly Cannot Upload Image and says Cannot Be Null

Greeting everyone and especially to Senior of CodeIgniter Developer.
I have a problem with website that was built from CodeIgniter (I am not the developer inherited by previous epmployer). This website cannot working properly, especially when upload the image and shows warning about
Error Number: 1048 Column 'article_image' cannot be null
I did try with find the problem on the script and database, but nothing change and because no one change the codes & contents. Today, i try again with changing the "Null into yes" (previously is "No"), and tried to upload the article. It is miracle that it is working but the next problem is the image is gone (broken). I search at other and looking people with same problem with me says that i need to upgrade the CodeIgniter. Mine is 3.0.0 while the latest is 3.1.10. I copy paste the content inside /System and /views/error/cli not making better but make it worse, the image at the web page is gone(missing).
This is my Article_model
defined('BASEPATH') OR exit('No direct script access allowed');
class Article_model extends CI_Model {
public function get_all()
{
// $this->db->order_by('article_date', 'desc');
// $this->db->order_by('article_view', 'desc');
// $query = $this->db->get_where('article', array('flag !=' => 3));
// return $query->result_array();
$query = $this->db->query("SELECT A.*,B.*, A.id AS id_article FROM article AS A JOIN category B ON A.article_category = B.id WHERE A.flag != 3 ORDER BY article_date DESC, article_view DESC ");
return $query->result_array();
}
public function check($article_id)
{
$query = $this->db->get_where('article', array('flag !=' => 3, 'id' => $article_id));
return $query->row_array();
}
public function get_category()
{
$query = $this->db->order_by('category_name', 'ASC')->get_where('category', array('flag' => 1));
return $query->result_array();
}
public function get_tag()
{
$query = $this->db->order_by('tag_name', 'ASC')->get_where('tag', array('flag' => 1));
return $query->result_array();
}
public function get_selected_tag($article_id)
{
$query = $this->db
->select('tag.id, tag_name')
->join('article_tag', 'tag_id = tag.id')
->where(array('tag.flag' => 1, 'article_id' => $article_id))
->get('tag');
return $query->result_array();
}
public function insert()
{
$this->load->helper('upload');
$this->load->library('image_moo');
$image = file_upload('article_image', 'upload/article');
$this->image_moo->load($image['full_path']);
$this->image_moo->resize(924, 527)->save($image['path'] . '/' . $image['file_name'], TRUE);
$this->image_moo->resize_crop(100, 69)->save($image['path'] . '/thumb/' . $image['file_name']);
$this->image_moo->resize_crop(367, 232)->save($image['path'] . '/cover/' . $image['file_name']);
$insert_data = array(
'article_author' => $this->session->admin_id,
'article_title' => $this->input->post('article_title'),
'article_slug' => url_title($this->input->post('article_title'), '-', TRUE),
'article_category' => $this->input->post('article_category'),
'article_image' => $image['file_name'],
'article_content' => $this->input->post('article_content'),
'is_popup' => $this->input->post('is_poup'),
'article_date' => $this->input->post('article_date'),
);
$this->db->insert('article', $insert_data);
$article_id = $this->db->insert_id();
foreach ($this->input->post('article_tag') as $tag)
{
// Check apakah tag itu udah ada di database?
if (is_numeric($tag))
{
$tag_id = $tag;
}
else
{
$this->db->insert('tag', array('tag_name' => strtolower(trim($tag)), 'tag_slug' => url_title(trim($tag), '-', TRUE)));
$tag_id = $this->db->insert_id();
}
if ( ! $this->db->get_where('article_tag', array('article_id' => $article_id, 'tag_id' => $tag_id))->row_array())
{
$this->db->insert('article_tag', array('article_id' => $article_id, 'tag_id' => $tag_id));
}
}
}
public function update($id)
{
$this->load->helper('upload');
$this->load->library('image_moo');
$image = file_upload('article_image', 'upload/article');
$this->image_moo->load($image['full_path']);
$this->image_moo->resize(924, 527)->save($image['path'] . '/' . $image['file_name'], TRUE);
$this->image_moo->resize_crop(100, 69)->save($image['path'] . '/thumb/' . $image['file_name']);
$this->image_moo->resize_crop(367, 232)->save($image['path'] . '/cover/' . $image['file_name']);
$insert_data = array(
'article_author' => $this->session->admin_id,
'article_title' => $this->input->post('article_title'),
'article_slug' => url_title($this->input->post('article_title'), '-', TRUE),
'article_category' => $this->input->post('article_category'),
'is_popup' => $this->input->post('is_popup'),
'article_content' => $this->input->post('article_content'),
'article_date' => $this->input->post('article_date'),
);
if ($image)
{
$insert_data['article_image'] = $image['file_name'];
}
$article_id = $id;
$this->db->where('id', $id);
$this->db->update('article', $insert_data);
$this->db->where('article_id', $id);
$this->db->delete('article_tag');
foreach ($this->input->post('article_tag') as $tag)
{
// Check apakah tag itu udah ada di database?
if (is_numeric($tag))
{
$tag_id = $tag;
}
else
{
$this->db->insert('tag', array('tag_name' => strtolower(trim($tag)), 'tag_slug' => url_title(trim($tag), '-', TRUE)));
$tag_id = $this->db->insert_id();
}
if ( ! $this->db->get_where('article_tag', array('article_id' => $article_id, 'tag_id' => $tag_id))->row_array())
{
$this->db->insert('article_tag', array('article_id' => $article_id, 'tag_id' => $tag_id));
}
}
}
}
What should i do guys? i did backup but it remain same like after upgraded. Thank you. Web Url (http://www.hidupseimbangku.com/)
First. If you want to upgrade CI Version you must follow Upgrading Guide one by one. There may be break changes and you need to correct them, you can find this guide here:
https://www.codeigniter.com/userguide3/installation/upgrading.html
I suggest you rollback upgrade changes and start again doing one by one. It is not hard, it is just time consuming.
The error you're getting is probably related to an error of uploading process. What is file_upload?
I also suggest you read this, for properly file upload.

typo3 how to add a second backend Module

in my typo3 extension I want to add a second backend modul in navigation.
in ext_tables.php I have this:
if (TYPO3_MODE === 'BE') {
/**
* Creates a Backend Module Category
*/
$modulName = 'InstitutsShop';
//Legt die Position des Moduls fest, hier nach Modul "web"
if (!isset($TBE_MODULES[$modulName])) {
$temp_TBE_MODULES = array();
foreach ($TBE_MODULES as $key => $val) {
if ($key == 'web') {
$temp_TBE_MODULES[$key] = $val;
$temp_TBE_MODULES[$modulName] = '';
} else {
$temp_TBE_MODULES[$key] = $val;
}
}
$TBE_MODULES = $temp_TBE_MODULES;
}
// Hauptmodul erstellen
t3lib_extMgm::addModule($modulName, '', '', t3lib_extMgm::extPath($_EXTKEY) . 'Configuration/BackendModule/');
/**
* Registers a Backend Module
*/
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
'TYPO3.' . $_EXTKEY, // $extensionName => vendor + extkey, seperated by a dot
'InstitutsShop', // $mainModuleName => Make module a submodule of 'Auditgarant'
'shopbackend', // $subModuleName => module name
'', // $position => position in the group
array( // Allowed controller -> action combinations
'ShopBackend' => 'list, showOrder',
),
array( // $moduleConfiguratione
'access' => 'user,group',
'icon' => 'EXT:' . $_EXTKEY . '/ext_icon_small.svg',
'labels' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang_shop_backend.xlf',
)
);
/**
* Registers a Backend Module
*/
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
'TYPO3.' . $_EXTKEY, // $extensionName => vendor + extkey, seperated by a dot
'InstitutsShop Produkte', // $mainModuleName => Make module a submodule of 'Auditgarant'
'shopbackendproducts', // $subModuleName => module name
'', // $position => position in the group
array( // Allowed controller -> action combinations
'ShopOrdProduct' => 'list',
),
array( // $moduleConfiguratione
'access' => 'user,group',
'icon' => 'EXT:' . $_EXTKEY . '/ext_icon_small.svg',
'labels' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang_shop_backend.xlf',
)
);
}
The first one with controller ShopBackend is displayed ...
The second one not.
What could be the issue in this case?
Thanks in advance.
I'd say that the space is not allowed in the mainModuleName. And I don't think that your extension has the vendor TYPO3.

magento 1.9.2.2 add to cart with custom option image not working

I have a script which adds a product in cart with custom option image and it was working perfect till CE 1.9.2.1 but after up gradation to latest version it troughs exception that Please specify the product's required option(s).
Below is code, please guide me if something has to change for newer version .
<?php
$productId = xxx;
$image = 'path to image(tested image exists)';
$product = Mage::getModel('catalog/product')->load($product_id);
$cart = Mage::getModel('checkout/cart');
$cart->init();
$params = array(
'product' => $productId,
'qty' => 1,
'options' => array(
$optionId3inmycase => array(
'type' => 'image/tiff',
'title' => $image,
'quote_path' => '/media/custom/' . $image,
'order_path' => '/media/custom/' . $image,
'fullpath' => Mage::getBaseDir() . '/media/custom/' . $image,
'secret_key' => substr(md5(file_get_contents(Mage::getBaseDir() . '/media/custom/' . $image)), 0, 20)),
)
);
$request = new Varien_Object();
$request->setData($params);
$cart->addProduct($product, $request);
$cart->save();
if ($itemId > 0) {
$cartHelper = Mage::helper('checkout/cart');
$cartHelper->getCart()->removeItem($itemId)->save();
}
Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
$this->_redirect('checkout/cart/');
?>
One quick solution is to rewrite Mage_Catalog_Model_Product_Option_Type_File class and change validateUserValue() function.
around line 129, replace
$fileInfo = $this->_getCurrentConfigFileInfo();
with
$fileInfo = null;
if (isset($values[$option->getId()]) && is_array($values[$option->getId()])) {
// Legacy style, file info comes in array with option id index
$fileInfo = $values[$option->getId()];
} else {
/*
* New recommended style - file info comes in request processing parameters and we
* sure that this file info originates from Magento, not from manually formed POST request
*/
$fileInfo = $this->_getCurrentConfigFileInfo();
}
but its old code and will have APPSEC-1079 security issue.
and to download image this uploaded image in order detail etc. add this function in same model class.
/**
* changed the image save address as we are saving image in custom
* Main Destination directory
*
* #param boolean $relative If true - returns relative path to the webroot
* #return string
*/
public function getTargetDir($relative = false)
{
$fullPath = Mage::getBaseDir('media') . DS . 'custom';
return $relative ? str_replace(Mage::getBaseDir(), '', $fullPath) : $fullPath;
}