We need set locale in data-dojo-config before dojo loaded so that dojo.i18n will work with this locale. Is there any workaround that we can change this locale in dojo/_base/config after dojo loaded so that any further dojo.i18n call will work with this new locale?
I have a single page application, by carefully design, I already be able to recreate all my UI widgets dynamically anytime. I want to add a Select somewhere so that user can change languages on the fly. Currently the only solution I have is put a queryString locale='newLocale' at Url and force browser refresh. That works but everything User have done lost and with a fresh start. That's not what I want.
Any idea? I don't afraid some changes of dojo to make this happen since my application will be built as a single layer and deploy to customers.
According to dojo's documentation, you cannot change the locale once it's loaded. See this page from their documentation, the relevant line is:
Once Dojo is loaded, it is not possible to change the locale for the
page.
Your description of adding a new parameter is what I've done in this situation, you can specify the locale property on the dojoConfig object to override the default locale.
EDIT: There is an open bug for this use case, see https://bugs.dojotoolkit.org/ticket/17196. In that ticket there also appears to be a workaround that basically involves manually loading the resource file of the language you want to use and updating any text.
So, adapting their example (http://jsbin.com/aquviq/1/edit), this would run after you initiate a change locale action:
require(['dojo/i18n!dojo/nls/' + resourceModuleWithLocale], function (resource) {
/* in here, you must set all of the text manually to the values in the resource object */
});
It still seems like a lot of work, but I suppose that's one possible way to accomplish this.
Related
I'm trying to make an Ajax-call to my Controller.
I placed a hidden link in my form like this:
<f:link.action action="ajaxCheckEmailExistsFE" controller="Profiles" class="hidden" id="checkEmailExistsAjaxLink"></f:link.action>
In my Javascript, I extract the href from this link:
var target = $('#checkEmailExistsAjaxLink').attr('href');
And then send my request with jQuery's $.post method.
When the link is called, I get the infamous error
The action \"ajaxCheckEmailExistsFE\" (controller \"Profiles\") is not allowed by this plugin. Please check TYPO3\\CMS\\Extbase\\Utility\\ExtensionUtility::configurePlugin() in your ext_localconf.php
But the action is clearly set in ext_localconf.php!
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'MyVendor.MyExt',
'MyPlugin',
[
'Profiles' => 'editFE, showFE, updateFE, ajaxCheckEmailExistsFE'
],
// non-cacheable actions
[
'Profiles' => 'editFE, showFE, updateFE, ajaxCheckEmailExistsFE'
]
);
The same workflow works perfectly in BE-Mode.
I had the same problem with the updateFE-Action. When the form was submitted, I got the same error like above. I had to add it to the switchable-controller-actions in my flexform (-> <numIndex index="1">Profiles->editFE;Profiles->updateFE</numIndex>) - which is equally odd.
Why is this happening???
This is TYPO3 9.5
[Edit] For the time being, I ended up adding the action to the switchable-controller-actions just like I did for the updateFE-Action.
This is VERY cumbersome, though, since I have to set the plugin-action on the page every time I add a new action.
If anybody has a better solution, I'd be extremely thankful!
Indeed, this IS cumbersome, but it is also the only working way for switchable actions in TYPO3 extbase controllers. This check is intended to ensure that specific actions are only callable when you are in the "correct" plugin, as you may have several plugins inside one extension, which then may utilize different actions. So in the end, this feature prevents one plugin to call an action which should only be callable inside another plugin of the same extension.
If you do not need the editor to switch action sets of your plugins though, you can remove this config part from your flexform, which will solve the need to edit this for new actions.
As a famous example, take a look into the config of the news extension. There is one plugin which allows list+detail view, and different ones for just list or just detail view. So as an admin, you have to choice of structuring your website (routing and templates) for different news setups.
Even in the TYPO3 community, there are voices to get rid of this feature, so maybe it will be solved in future versions.
I am creating apps using Podio PHP library and want to specify always hidden setting. I have tried it a lot but I did not find any option in the library so can someone please help me to point out how I can specify this setting.
After investigation, I am able to figure it out like how to pass the always hidden. When we are creating an app with fields then for each field we need to provide config array so in this config array we need to pass new property "hidden_create_view_edit" with true and it will create app field with always hidden setting.
Sample config array:
"config"=>array(
"required"=>false,
"label"=>"Name",
"delta"=>1,
"hidden_create_view_edit"=>true
)
In IBM Content Navigator, The "Check In" dialogue contains a Properties Pane, that in turn contains a Class Selector drop down box.
ClassSelector image
I want to keep the check-in functionality, but would like to have that Class Selector box not appear (There is no use case where a user would need to change the document class).
What would be the proper way to achieve this?
Is there a way to extend the ecm/widget/CheckInDialogue.js file AND make the default checkIn action use my new js?
Do I need to create a brand new checkIn action that references a new js?
Do I just change the ICN shipped js/html?
Just to clarify, I do know how to create a plugin, and how to create a js extension to the checkinDialogue.js, and how to remove the classSelector; however I don't know how to make the checkin action use my new script, or the best way to accomplish this.
Thanks!
Before answering your question, I would like to say that I think there is other options to do this without customizing ICN. The two easiest I can see would be:
Use entry templates, that way class selector will be disable on check in by default
Remove the privChangeClass privilege, that should hide the Class Selector (might be difficult if you want to leave full priv.)
Now if you want to hide it without using entry templates or privileges.
Yes, extend the ecm.widget.layout.CommonActionHandler and overwrite the actionCheckIn function and use your CheckInDialog instead of the default one. Then use your CommonActionHandler instead of the default one in your desktop. I don't think there is a way to change the ActionHandler from the admin desktop UI yet (if I missed it please let me know), although it's loaded by the client on the _loadDesktop function and set by the appearance tab but the value is hard-coded, so you might have to inject it after the load of better, call ecm.model.desktop.setActionHander(actionhandler) where actionhandler is the instance, not the class name (string) in a plugin.
You can, this will make things easier to manage if you have several desktops and you want some to use your new Check In dialog and some not.
No, that's a terrible idea :) Future upgrade of ICN and your code will be a nightmare and the delivery process a lot more complex than a simple configuration trick or ICN plug-in, that's what plug-ins are for.
Also a not so clean but really simple solution would be to aspect after the CheckInDialog.prototype on the postCreate function and do a domStyle.set(this.addContentItemPropertiesPane._contentClassSelectorDiv, "display", "none"); to just hide it on all CheckInDialogs.
I am testing my web application using Selenium. All the form validation in the web application is done by HTML5 and some JS(for safari browser). I want to know what is the proper way to test the form validation.
Currently I am using one approach, i.e Before I filled up a mandatory field I clicked on the submit button. If the page is not refreshed then I assume the form validation working correctly. But I think there should be a better approach to do it. I am unable to find any proper solution. Any suggestion will be highly appreciated.
I also go through this link. But it is not working for me because it is not enough to have required attribute (eg required attribute does not work in older Safari browser).
Rather than checking if the page is refreshed or not, you should instead expect that it is not and that a certain error message or field highlighting or something is applied to the current page. When in an error state, the input fields probably get given an extra class, or an error div/span might be added to the DOM, try checking for that sort of thing
Situation: I needed to add form with POST method to CMS page. I created custom hook and a module displaying the form successfully. Then I need to react to user input errors eg. when user doesn't enter email address I need to detect it, display the whole page again together with the form and with "errors" in user input clearly stated.
Problem: The problem is to display the WHOLE page again with connected information (eg. about errors etc.). In the module PHP file when I add this kind of code,
return $this->display(__FILE__, 'modulename.tpl');
it (naturally) displays ONLY the form, not the whole CMS page with the form.
In case of this code,
Tools::redirectLink('cms.php?id_cms=7');
I can't get to transfer any information by GET neither POST method.
$_POST['test'] = 1;
Tools::redirectLink('cms.php?id_cms=7&test');
I tried to assign to smarty variables too
$smarty->assign('test', '1');
(I need to use it in .tpl file where the form itself is created) but no way to get it work.
{if isset($test)}...,
{if isset($smarty.post.test)}...,
{if isset($_POST['test'])}... {* neither of these conditionals end up as true *}
Even assigning a GET parameter to url has no impact, because there is link rewriting to some kind of friendly url I guess, no matter I included other argument or not. ([SHOPNAME]/cms.php?id_cms=7&test -> [SHOPNAME]/content/7-cmspage-name)
My question is: is there a way to "redirect" or "reload" current page (or possibly any page generally) in prestashop together with my own data included?
I kind of explained the whole case so I'm open to hear a better overall solution than my (maybe I'm thinking about the case in a wrong way at all). This would be other possible answer.
The simplest method would be to use javascript to validate the form - you can use jQuery to highlight the fields that are in error; providing visual feedback on how the submission failed. In effect you don't allow the user to submit the form (and thus leave the page) until you're happy that the action will succeed. I assume that you will then redirect to another page once a successful submission has been received.
There's lots of articles and how-tos available for using javascript, and indeed jQuery for form validation. If you want to keep the site lean and mean, then you can provide an override for the CMS controller and only enqueue the script for the specific page(s) you want to use form validation on.
If the validation is complex, then you might be best using AJAX and just reloading the form section of your page via a call to your module. Hooks aren't great for this kind of thing, so you might want to consider using an alternative mnethod to inject your code onto the cms page. I've written a few articles on this alternative approach which can be found on my prestashop blog