I have a TYPO3 frontend plugin and now I want two different ways to display the "list" controller. How can I achieve this?
You need to use flexform for frontend plugin like below.
In your ext_tables.php file.
//extenstion name
$extensionName = \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($_EXTKEY);
//plugin integration
$frontendpluginName = 'Plugin name';
$pluginSignature = strtolower($extensionName) . '_'.strtolower(
$frontendpluginName
);
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue(
$pluginSignature,
'FILE:EXT:' . $_EXTKEY . '/Configuration/FlexForms/configure.xml'
);
Now create configure.xml file on this path /Configuration/FlexForms/
<T3DataStructure>
<sheets>
<!--
################################
SHEET General Settings
################################
-->
<sDEF>
<ROOT>
<TCEforms>
<sheetTitle>General</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<!-- View -->
<settings.layout>
<TCEforms>
<label>Select Frontend Layout</label>
<config>
<type>select</type>
<items>
<numIndex index="0">
<numIndex index="0">Layout 1</numIndex>
<numIndex index="1">1</numIndex>
</numIndex>
<numIndex index="1">
<numIndex index="0">Layout 2</numIndex>
<numIndex index="1">2</numIndex>
</numIndex>
</items>
<size>10</size>
<minitems>0</minitems>
<maxitems>1</maxitems>
<suppress_icons>1</suppress_icons>
</config>
</TCEforms>
</settings.layout>
</el>
</ROOT>
</sDEF>
</sheets>
</T3DataStructure>
Now use this value in frontend template files like below.
<f:if condition="{settings.layout} == 1">
<f:then>
Layout 1 html
</f:then>
<f:else>
Layout 2 html
</f:else>
</f:if>
I haven't used this in a while so I am not 100% this is still relevant, the API docs suggest that you can still do this though:
public function listAction() {
{your_code}
$this->view->setTemplatePathAndFilename(
'typo3conf/ext/' .
$this->request->getControllerExtensionKey() .
'/{path_to}/OtherTemplate.html');
$this->view->assign(...);
}
If you need to switch this on a per plugin base decide which template to use by reading a configuration variable.
Related
I have created a FlexForm for my typo3 backend to choose some options:
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3DataStructure>
<sheets>
<sDEF>
<ROOT>
<TCEforms>
<sheetTitle>
</sheetTitle>
</TCEforms>
<el>
<settings.maxNumber>
<TCEforms>
...
<settings.orderBy>
<TCEforms>
<label>My selections</label>
<config>
<type>select</type>
<renderType>selectSingle</renderType>
<items>
<numIndex index="0">
<numIndex index="0">Title first</numIndex>
<numIndex index="1">title,year,author</numIndex>
</numIndex>
<numIndex index="1">
<numIndex index="0">Year first</numIndex>
<numIndex index="1">year,title,author</numIndex>
</numIndex>
<numIndex index="2">
<numIndex index="0">Author first</numIndex>
<numIndex index="1">author,year,title</numIndex>
</numIndex>
</items>
</config>
</TCEforms>
</settings.orderBy>
<!-- end of settings -->
</el>
</ROOT>
</sDEF>
</sheets>
</T3DataStructure>
My problem is that the first entries in the dropdown menu in the backend are
1. [INVALID VALUE ("author")][author]
2. [INVALID VALUE ("title")][title]
3. [INVALID VALUE ("year")][year]
then the other options follow as expected.
Documentation about "items" array in "select" type about the second value says:
Values must not contain “,” (comma) and “|” (vertical bar). If you want to use “authMode” you should also refrain from using “:” (colon).
https://docs.typo3.org/m/typo3/reference-tca/9.5/en-us/ColumnsConfig/Type/Select.html#items
It means you should probably use a different separator for those values to avoid the issue you're facing.
In general you use flexforms to offer custom TYPO3 plugin settings. So I've setup the following lines in my ext_tables.php:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'DS.Dscontrolpanel',
'Dsentitymodullist',
'Entitymodullist'
);
// ...
// Flexform
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['dscontrolpanel_entitymodullist'] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue('dscontrolpanel_entitymodullist','FILE:EXT:dscontrolpanel/Configuration/FlexForms/flexform_dscontrolpanel.xml');
and start a little test flexform just to test it (flexform_dscontrolpanel.xml):
<T3DataStructure>
<ROOT>
<TCEforms>
<sheetTitle>Test 1</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<test>
<TCEforms>
<label>Test 2</label>
<config>
<default>1</default>
<type>check</type>
<items type="array">
<numIndex index="1" type="array">
<numIndex index="0">enabled</numIndex>
<numIndex index="1">1</numIndex>
</numIndex>
</items>
</config>
</TCEforms>
</test>
</el>
</ROOT>
After that I cleared both the TYPO3 cache and the PHP opcode cache. But nothing happens in my FE Plugin form. Is there a new way in TYPO3 7.6+ to add custom settings to TYPO3 FE plugins or do I just miss something?
I think you have build wrong the plugin siganture.
dscontrolpanel_dsentitymodullist instead of dscontrolpanel_entitymodullist
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'DS.Dscontrolpanel',
'Dsentitymodullist',
'Entitymodullist'
);
// ...
// Flexform vv
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['dscontrolpanel_dsentitymodullist'] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue(
// vv
'dscontrolpanel_dsentitymodullist',
'FILE:EXT:dscontrolpanel/Configuration/FlexForms/flexform_dscontrolpanel.xml'
);
Why don't you just register a frontend plugin? Then it will automatically generate a flexform for you, which you can extend, plus it will give you this by default
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue($pluginSignature, 'FILE:EXT:' . $extKey . '/Configuration/FlexForms/flexform_your_extension.xml');
I will not change my first answer, but apparently i was wrong. Follow these steps and you ll be able to add your FlexForm:
Just in case
$pluginSignature = str_replace('_', '', $extKey) . '_yourextensionKey';
Register your FlexForm:
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
Find your FlexForm:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue($pluginSignature, 'FILE:EXT:' . $extKey . '/Configuration/FlexForms/FlexFormNameHere.xml');
I'm trying to update a custom field with a file type using rest API.
After properly uploading a file using:
curl --data-binary "#test.pdf" -H "Content-Type: application/octet-stream" -X POST -H "X-Redmine-API-Key: e1d815b8963e7b3950d4bea47959f874be755a2c" https://redmine-dev/uploads.xml
I get my token:
<?xml version="1.0" encoding="UTF-8"?>
<upload>
<id>15</id>
<token>15.cb4...</token>
</upload>
And then I tried to update the custom filed using those and none worked:
<?xml version="1.0"?>
<issue>
<custom_fields type="array">
<custom_field id="4">
<token>15.cb4...</token>
<filename>test.pdf</filename>
</custom_field>
</custom_fields>
</issue>
<?xml version="1.0"?>
<issue>
<custom_fields type="array">
<custom_field id="4">
<value>
<token>15.cb4...</token>
<filename>test.pdf</filename>
</value>
</custom_field>
</custom_fields>
</issue>
<?xml version="1.0"?>
<issue>
<custom_fields type="array">
<custom_field id="4">
<value>15</value>
</custom_field>
</custom_fields>
</issue>
After each the field is cleared in the database.
Updating a different custom field (text and number based) alongside of each of those is working. I've also checked the docs and there is nothing detailing how to use REST to update custom attachments.
It was so easy after looking into the code, but the token has to belong to previously unused attachment.
<?xml version="1.0"?>
<issue>
<custom_fields type="array">
<custom_field id="4">
<value>
<token>15.cb4...</token>
</value>
</custom_field>
</custom_fields>
</issue>
With zend framework how do i create a single level menu?
I followed a tutorial and the person created a two level dropdown menu. I want to just remove home. I've modified the navigation.xml file a couple times and it caused a fatal error.
What xml markup do i need to promote the children of home as the parent level menus? As in i don't need a home button at all.
Desired outcome:
who
why
what
speaker
resources
Current outcome:
home
• who
• what
• when
• why
Current navigation.xml file:
<?xml version="1.0" encoding="UTF-8" ?>
<configdata>
<nav>
<home>
<label>Home</label>
<controller>page</controller>
<action>index</action>
<module>default</module>
<pages>
<why>
<label>why</label>
<controller>page</controller>
<action>why</action>
<module>default</module>
</why>
<who>
<label>who</label>
<controller>page</controller>
<action>who</action>
</who>
<resources>
<label>resources</label>
<controller>page</controller>
<action>resources</action>
</resources>
<signin>
<label>sign in</label>
<controller>account</controller>
<action>login</action>
<module>default</module>
</signin>
</pages>
</home>
</nav>
...
application/Bootstrap.php:
<?php function _initViewHelpers() {
$this->bootstrap('layout);
// ... Skipping to relevant part
$navContainerConfig = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');
$navContainer = new Zend_Navigation($navContainerConfig);
$view->navigation($navContainer);
} ?>
layouts/default.phtml
<div class="navigation"><?php print $this->navigation(); ?></div>
<?xml version="1.0" encoding="UTF-8" ?>
<configdata>
<nav>
<why>
<label>why</label>
<controller>page</controller>
<action>why</action>
<module>default</module>
</why>
<who>
<label>who</label>
<controller>page</controller>
<action>who</action>
</who>
<resources>
<label>resources</label>
<controller>page</controller>
<action>resources</action>
</resources>
<signin>
<label>sign in</label>
<controller>account</controller>
<action>login</action>
<module>default</module>
</signin>
</nav>
What about setMaxDepth() and setMinDepth()? You can set how deep you want your menu to be rendered:
<?= $this->navigation()->menu()
->setMinDepth(1)
->setMaxDepth(2)
->render() . PHP_EOL; ?>
Also, you can find more information about the navigation view helper in the official manual. These information are often more relevant than the ones you can find in tutorials.
you should be able to just adjust your container to display only the links you want displayed. In this case you would just remove the Home elements from your xml file.
<?xml version="1.0" encoding="UTF-8" ?>
<configdata>
<nav>
<pages>
<why>
<label>why</label>
<controller>page</controller>
<action>why</action>
<module>default</module>
</why>
<who>
<label>who</label>
<controller>page</controller>
<action>who</action>
</who>
<resources>
<label>resources</label>
<controller>page</controller>
<action>resources</action>
</resources>
<signin>
<label>sign in</label>
<controller>account</controller>
<action>login</action>
<module>default</module>
</signin>
</pages>
</nav>
When you remove the Home menu from the XML file , you get an exception
Zend_Navigation_Exception: Invalid argument: Unable to determine class to instantiate in C:\www\project\library\Zend\Navigation\Page.php on line 235
i have this xml file for Creating a container ,
if i want create a db for save this items and and create container from db
how should i do ?
<?xml version="1.0" encoding="utf-8"?>
<config>
<nav>
<logout>
<label>logout</label>
<controller>authentication</controller>
<action>logout</action>
<resource>logout</resource>
</logout>
<login>
<label>login</label>
<controller>authentication</controller>
<action>login</action>
<resource>login</resource>
</login>
<test>
<label>test</label>
<uri>#</uri>
<resource>test</resource>
<pages>
<list>
<label>list</label>
<controller>tset</controller>
<action>listtest</action>
</list>
<archive>
<label>archive</label>
<controller>myarchive</controller>
<action>archive</action>
</archive>
</pages>
</test>
</nav>
</config>
and code in bootsrap
$navContainerConfig = new Zend_Config_Xml(APPLICATION_PATH . 'navigation.xml', 'nav');
$navContainer = new Zend_Navigation($navContainerConfig);
Why do you need to store this in database?
If you really need, the best way is nested set.
You may also just serialize the array and save to the database.
You may also use Zend_Config_Xml_Writer instead of the database.