How to add custom wizards in typo3 7 TCA? - typo3

When I try to add the wizard named wizard_geo_selector in TCA ,there arised an error "module not registered".Please tell me how to register the wizard properly in the TCA.?

In TYPO3 Version 7.6 new wizards are added like this:
Inside your extension create the directory Configuration/Backend/
In the new directory create a file Routes.php, it will be found automatically, no mentioning in ext_localconf.php or ext_tables.php is required. If you still need Ajax you can add the file AjaxRoutes.php in the same folder.
Content for Routes.php:
return array(
'my_wizard_element' => array(
'path' => '/wizard/tx_geoselecotor/geo_selector_wizard',
'target' => \Path\To\your\class\WizardGeoSelector::class . '::WizardAction'
),
);
Content for AjaxRoutes.php
<?php
/**
* Definitions for routes provided by EXT:backend
* Contains all AJAX-based routes for entry points
*
* Currently the "access" property is only used so no token creation + validation is made
* but will be extended further.
*/
return array('my_ajax_element' => array(
'path' => 'tx_geoselecotor/my_ajax_route',
'target' => \Path\To\your\class\MyAjaxController::class .'::myAjaxFunction'
));
If you're unsure about the notation you can compare with existing entries in the Global Variables in the Backend:
Navigate to System -> Configuration -> Backend Routes
The route of the paths is handled different, for Ajax it's always "ajax" prepended, so you've never to add it to the path, else it's twice in the route. For the common route there is no change concerning the defined string.
Now the wizard can be used and even it never has to be defined in ext_tables.php it has to be mentioned there from any table-field in the configuration-area (module[name]):
'table_field_for_wizard' => array(
'label' => 'LLL:EXT:my_extension/Resources/Private/Language/locallang.xml:table_name.tx_myextension_wizard',
'config' => array (
'type' => 'user',
'userFunc' => 'Path/to/class/without/wizard->renderForm',
'wizards' => array(
'my_wizard' => array(
'type' => 'popup',
'title' => 'MyTitle',
'JSopenParams' => 'height=700,width=780,status=0,menubar=0,scrollbars=1',
'icon' => 'EXT:' . $_EXTKEY . '/Resources/Public/img/link_popup.gif',
'module' => array(
'name' => 'my_wizard_element',
'urlParameters' => array(
'mode' => 'wizard',
'ajax' => '0',
'any' => '... parameters you need'
),
),
),
'_VALIGN' => 'middle',
'_PADDING' => '4',
),
# Optional
#'softref'=>'something',
),
),
In the userFunc Path/to/class/without/wizard->renderForm you've to create a button which is linking to the wizard and onClick the wizard will open with the route you defined in Routes.php and the optional urlParameters.
Currently I never found this whole item explained in the core-documentation.
Edit:
Details about routing can be found here: Routing
The rendering process can be found here: Rendering / NodeFactory
You should probably read also the outer context of the linked paragraph.
Edit 2:
An example extension can be found here, some things never work 100% but the wizard is working. The extension is for TYPO3 Version 7:
https://github.com/DavidBruchmann/imagemap_wizard

Ricky's answer doesn't really work anymore, since addModulePath ist deprecated since version 7.
Also, just registering the module like this still give's you said error.
The only thing that keeps the wizard going again is this:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule('wizard','pbsurvey_answers',"",\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY).'wizard/');
But when you add this, the module appears as a new point in your TYPO3 backend.

IN TCA add the wizard like follows:
'module' => array(
'name' => 'wizard_geo_selector',
),
In ext_tables.php register the wizard.
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModulePath(
'wizard_geo_selector',
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Modules/Wizards/Yourwizardname/'
);
Keep in mind this is deprecated since Typo3 7 and removed in Typo3 8.So you can use this method upto Typo3 7.For Typo3 8 do use the method specified by David below.

Related

TYPO3 9.5.x with news 7.2.x: Custom properties

I've extended TYPO3 9.5.x with news extension 7.2.x with some custom properties.
I used the manual I found here.
In general, everything works, but somehow the custom properties I created seem to be blank at the frontend. After clearing the cache, everything works again, but after some time the same issue appears again.
What am I doing wrong? Maybe it has something to do that I'm working with TYPO3 9.5.x and the manual is written for TYPO3 7.6.x?
Thanks for your help!
move your TCA modifying code (from ext_tables) to /typo3conf/ext/yourEXT/Configuration/TCA/Overrides/tx_news_domain_model_news.php
something like this:
defined('TYPO3_MODE') or die();
( function( &$tca) {
$tempColumns = array(
'NEW_FIELD' => array(
'exclude' => 0,
'label' => 'LLL:EXT:yourEXT/Resources/Private/Language/locallang_be.xlf:tx_newsextend_domain_model_news.NEW_FIELD',
'config' => array(
'type' => 'check',
'default' => 0
),
),
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
'tx_news_domain_model_news',
$tempColumns
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes("tx_news_domain_model_news", 'NEW_FIELD', '', 'after:title');
})( $GLOBALS['TCA']['tx_news_domain_model_news']);

TYPO3: How to set up textfield in custom content element to avoid missing file references in backend filelist?

How to set up textfield in custom content element to avoid missing file references in backend filelist
I have a custom content element with a field of type "text". When I link in this field to a file in fileadmin there is no reference counted in the backend.
How I have to configure the field in my TCA to regard the references from that field in the file list?
My TCA-Config for that field is:
'my_ext_fiedname' =>
array(
'config' =>
array(
'type' => 'text',
'eval' => 'required',
'richtextConfiguration' => 'default',
'enableRichtext' => '1',
),
'exclude' => '1',
'label' => 'title',
),
Try to avoid using media references in text fields. It has been difficult over the past years to upgrade TYPO3 with such configuration and usages.
If you can't avoid, try using extension rte_ckeditor_image from Christian Opitz which is regularly maintained.

How to set configurations for use in TCA/Overrides or how to configure sys categories?

For an extension i like to use sys_categories that are stored in a dedicated folder. How do I configure the folder and access the configuration inside the TCA setup?
I tried this approach. I use the method \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::makeCategorizable inside Configuration/TCA/Overrides/tx_xref_domain_model_project.php.
Where I place the hardcoded 333 I would like to use a configuration value in the ideal case tsconfig. Is it parsed and accessible at this point?
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::makeCategorizable(
'xref',
'tx_xref_domain_model_project',
'areas',
array(
'label' => 'Areas',
'exclude' => FALSE,
'fieldConfiguration' => array(
'foreign_table_where' => ' AND sys_category.pid = 333',
)
)
);
Is there a more easy approach to solve this?
Using ExtensionManagementUtility::makeCategorizable() in Configuration/TCA/Overrides/<your_table>.php is exactly the right approach and in fact what TYPO3 itself does.
At least the global extension configuration is accessible at this point.
https://docs.typo3.org/typo3cms/CoreApiReference/ExtensionArchitecture/ConfigurationOptions/Index.html
This is not fully satisfying, as you may want to define a different category source folders for different pages or sys_folders. Yet it will do for many projects:
$areaFolder = (int)\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class)
->get('xref', 'areaFolder');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::makeCategorizable(
'xref',
'tx_xref_domain_model_project',
'areas',
array(
'label' => 'Areas',
'exclude' => FALSE,
'fieldConfiguration' => array(
'foreign_table_where' => ' AND sys_category.pid = ' . (string) $areaFolder,
)
)
);

How to create a custom API route in SocialEngine Zend

I have created a new REST API module in SocialEngine which can be browsed via http://server_address/mymodule or http://server_address/mymodule/index. I have a controller class Mymodule_IndexController inside thecontrollers directory. It has a method indexAction in which I output some JSON response. It works.
The question is, how can I add another route and corresponding action e.g. food/browse in this module. I have already added the following routes inside manifest.php, but when I browse to http://server_address/mymodule/browse, the route is not resolved (Page not found error).
'routes' => array(
'food_general' => array(
'route' => 'advancedrestapi/:controller/:action/*',
'defaults' => array(
'module' => 'advancedrestapi',
'controller' => 'index',
'action' => 'index',
),
'reqs' => array(
'controller' => '\D+',
'action' => '\D+',
),
),
How can I introduce new custom routes and corresponding PHP method to my module?
To add a custom route, you need to add a file with the same name as your 'action' and then .tpl extension. So, for the route in question ('action'=>'browse'), you will need to have a file as application/modules/mymodule/views/scripts/index/browse.tpl. The file can be empty.
Then, you will need to add a new method to your IndexController class browseAction (action + Action). Write your logic inside the method and you will be able to access the action via http://server_address/mymodule/index/browse.

how to change default module in Zend 2

I am new to ZendFeamerwork version 2. I could easily change the default controller in Zend1 but it seems very difficult to me to find out how to change default module in Zend2.
I searched over google but there is no easy solution.
I just created a module named "CsnUser" I can access this module via the following url
http://localhost/zcrud/public/csn-user/
I want csn-user to load instead of "application" module i.e url should be
http://localhost/zcrud/public/
or
http://localhost/zcrud/
Please let me know how to get this done.
Based on #Hoolis comment:
You have to set that action on this route
'home' => array(
'type' => 'Literal',
'options' => array(
'route' => '/',
'defaults' => array(
'controller' => 'That\Namespace\CsnUser',
'action' => 'index'
)
)
)
)
In the skeleton application this route is set in the Application Module, but you can move this somewhere or edit it.