Message in the backend of typo3 - typo3

I've tried to add some message in typo3 backend, but without success.
I know for Flash messages but I just can't make it work.
How can I make it work?

I did this in one of my extensions and here is the snippet:
$messageQueue = GeneralUtility::makeInstance(
FlashMessageQueue::class,
'core.template.flashMessages'
);
$messageQueue->addMessage(
new FlashMessage(
'text',
'title',
FlashMessage::OK,
true
)
);
Most important is the attribute 'core.template.flashMessages' when instantiiating the FlashMessageQueue.

Related

Which files are needed for an own finisher to work in the Typo3 form extension?

I want to make my own finisher but I don't have a clue what is needed.
I have
\Domain\Finishers\MyOwnFinisher.php // with the finisher class
Configuration\Form\Backend.yaml //which should tell my TYPO3 where to look for the finisher
Configuration\TypoScript\setup.typoscript //telling EXT:form where the Backend.yaml is
but still I get an exception:
"The finisher preset identified by “xxx” could not be found, or the implementationClassName was not specified."
Is there some file I forgot? Some configuration I must set?
Backend.yaml
prototypes:
standard:
finishersDefinition:
MyOwn:
implementationClassName: 'mastar\testprivateext\Classes\Domain\Finishers\MyOwnFinisher'
options:
table: tx_testprivateext_domain_model_YetAnotherTable
setup.typoscript
#import "EXT:testprivateext/Configuration/TypoScript/Setup/*.typoscript"
plugin.tx_form.settings.yamlConfigurations {
901 = EXT:testprivateext/Configuration/Form/Backend.yaml
}
MyOwnFinisher.php
<?php
declare(strict_types=1);
namespace mastar\testprivateext\Classes\Domain\Finishers;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
use TYPO3\CMS\Form\Domain\Finishers\Exception\FinisherException;
use TYPO3\CMS\Form\Domain\Model\FormElements\FormElementInterface;
use TYPO3\CMS\Form\Domain\Finishers\AbstractFinisher;
class MyOwnFinisher extends AbstractFinisher {
protected $defaultOptions = [
'table' => 'tx_testprivateext_domain_model_YetAnotherTable',
'pid' => '34',
'name' => '',
'unterzeile' => '',
'strasse' => '',
'hausnummer' => '',
'plz' => '',
'ort' => '',
'telefon' => '',
'fax' => '',
'web' => '',
];
protected $shortFinisherIdentifier = 'MyOwn';
protected $databaseConnection;
protected function executeInternal() {
/// Stuff get's done here
}
}
Thanks in advance!
You have some definition in the yaml file, I complete it as I never know if you missed it or left it out:
TYPO3:
CMS:
Form:
prototypes:
standard:
finishersDefinition:
MyOwn:
implementationClassName: 'mastar\testprivateext\Classes\Domain\Finishers\MyOwnFinisher'
options:
table: tx_testprivateext_domain_model_YetAnotherTable
Beside that I never see an obvious fault and guess that you know the documentation how to write an own finisher.
One issue when new classes are added can sometimes be solved by clearing the cache and dumping autoload.
Furthermore it might be helpful to check the logfile, not all problems are reported by the log inside the TYPO3 backend.
EDIT:
I just see this is wrong:
implementationClassName:
'mastar\testprivateext\Classes\Domain\Finishers\MyOwnFinisher'
and should be instead:
implementationClassName:
'mastar\testprivateext\Domain\Finishers\MyOwnFinisher'
So actually you've to separate paths and namespace, they are similar but not the same. Important might be the vendor and extensionName in the namespace too, I'd advise to read the extbase tutorial if you never understand namespaces well.

flatsome WooCommerce change postcode to dropbox

im new in WordPress i wan to change my WooCommerce check out form postcode to dropdown box.. im using the solution given online but it's not work on my page.. pls help me.
here the code i put inside flatsome child function file.
add_filter( 'woocommerce_default_address_fields' , 'customize_postcode_fields' );
function customize_postcode_fields( $adresses_fields ) {
$adresses_fields['postcode']['type'] = 'select';
$adresses_fields['postcode']['options'] = array(
'' => __('Select your postcode', 'woocommerce'),
'option_1' => 'Choice 1',
'option_2' => 'Choice 2',
'option_3' => 'Choice 3'
);
return $adresses_fields;
}
and the result that i get after apply the code
my display after apply
I have updated my post from earlier which may make it easier for you to interpret and put into your code (I changed it from my last answer, as what I published wont work) - the main difference is putting the array into a variable, to make it easier to change in the future. I have done some research as well and found that the information you provided was the best option for this (so I just cleaned it up a bit). However, if you could also inspect/view-source on your code
function wpe_0987_customize_postcode_fields( $postcode_field ) {
$options = array(
'' => __( 'Select...', 'woocommerce' ),
'choice_1' => 'choice_1',
'choice_2' => 'choice_2',
'choice_3' => 'choice_3',
'choice_4' => 'choice_4'
);
$fields['billing_postcode']['type'] = 'select';
$fields['shipping_postcode']['type'] = 'select';
$fields['billing_postcode']['options'] = $options;
$fields['shipping_postcode']['options'] = $options;
return $fields;
}
For Shipping Field Only!
add_filter( 'woocommerce_shipping_fields' , 'wpe_0987_customize_postcode_fields' );
For Shipping and Billing Fields
add_filter( 'woocommerce_default_address_fields' , 'wpe_0987_customize_postcode_fields' );
Also, when you create custom functions, don't forget to put a custom prefix at the start. At the moment you have 'customize_postcode_fields', you should find a series of letters/numbers or something unique to you to ensure that it doesn't clash with any other theme/plugin - eg: 'random123_customize_postcode_fields' and use that prefix on all custom functions you create in that project.
Update:
Do an 'inspect' or 'view source' on the page, check to see what the 'name' of the postcode form is, and update it with one of the two that I have provided above (shipping_postcode, billing_postcode).

TCA Icon overlay in typo3 backend

I’m working on an extension where I synchronise some data to another database and I wanted to show this in the backend using a TCA icon overlay. Sadly I could not find out how to do this. I thought about using ‘ctrl’=>‘typeicon_classes’ (using the state field of my table to choose an icon), this works for the default (non synchronised element) but I cannot figure out how to set an overlay. Any idea on how to do this?
My TCA configuration looks like this:
'ctrl' => [
...
'typeicon_column' => 'state',
'typeicon_classes' => [
'new' => 'mimetypes-x-content-login',
'synced' => 'mimetypes-x-content-login-overlay-approved',
]
],
The "synced" part does not work as expected. What I would expect is to either add the overlay at the end of the icon or by adding it with a whitespace but both did not work.
Any help is appreciated.
PS: I really just need this in the TYPO3 backend, the obvious solution for frontend is to use fluid or PHP but I don't think this suits the TYPO3 Backend list.
You need to register your icon files.
Given your icon files are named content_login.svg and content_login_overlay_approved.svg located in directory /Resources/Public/Icons/ you can register these in ext_localconf.php as following:
if (TYPO3_MODE === 'BE') {
$icons = [
'mimetypes-x-content-login' => 'content_login.svg',
'mimetypes-x-content-login-overlay-approved' => 'content_login_overlay_approved.svg',
];
$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);
foreach ($icons as $identifier => $path) {
$iconRegistry->registerIcon(
$identifier,
\TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
['source' => 'EXT:YOUREXTENSIONNANME/Resources/Public/Icons/' . $path]
);
}
}
Adapt yourextensionname

zend framework 2 how disable multiple errors messages of validator

I am trying to de that the EmailValidator class return me only one error messages.
In other forums I have seen that in ZF1 only is possible make it extending the Validator class.
Anybody know if in ZF2 there is a more easy way for make it?
This is my code for if anyone it help, in this I call setMessages method for overwrite the default messagestemplate, but not works.
$form = new ParticipantForm();
$mailInput = new Input('mail');
$validator = new ValidatorEmailAddres();
$validator->setMessages(
array(
ValidatorHostName::UNKNOWN_TLD => 'hola'
)
);
$mailInput->getValidatorChain()->addValidator($validator);
$mailInputFilter = new InputFilter();
$mailInputFilter->add($mailInput);
$form->setInputFilter($mailInputFilter);
$form->setData($_POST);
Try this:
$validator = new \Zend\Validator\EmailAddres();
$validator->setMessage('something broke bla');
or to set a specific message:
$validator = new \Zend\Validator\EmailAddres();
$validator->setMessage('something broke bla', \Zend\Validator\EmailAddres::LENGTH_EXCEEDED);

zend validator Zend_Validate_EmailAddress does nothing: site config looks OK, but probably isn't

Baffled again. (Zend Framework 1.11.1)
I've just added a validator to a VERY simple form, and nothing happens when invalid data is entered.
The code:
$form = new Zend_Form;
$form->setAction('/MyController/reponsepage')
->setMethod('post');
$form->setAttrib('id', 'firstTestForm');
$form->addElement('text', 'email', array('label' => 'EMail', 'value' => $this->_user['email']));
$form->addElement('hidden', 'expertID', array('value' => $_targetExpertID));
$form->addElement('submit', 'Submit and Be Free!');
$v = new Zend_Validate_EmailAddress();
$v->setMessage('Please enter a valid email address.');
$mailElem = $form->getElement('email')
->addValidator($v)
->setRequired(true);
$this->view->form = $form;
setRequired seems to do nothing. Leaving the field empty and hitting submit goes right through.
Garbage data also goes right through.
No error messages, nothing.
The library directory contains:
PATH_BLAH\library\Zend\Validate.php and
PATH_BLAH\library\Zend\Validate\ with all the normal stuff
It's sort of hard to guess what might be wrong.
I'd be much obliged for any clue that might come to your mind.
Thanks for reading.
Are you passing the data through to the form?
if ($this->getRequest()->isPost()
&& $form->isValid($this->getRequest()->getPost())) {
// process form
}
Phil Brown nailed it.
I had actually neglected to read back the post.
Head-slap here ...