cdaecke / md_newsfrontend

This TYPO3 extension enables feUsers to create news records in the frontend.
Other
3 stars 3 forks source link

Is it possible to change the date? #17

Closed bachblick closed 4 years ago

bachblick commented 5 years ago

It would be perfect, if the fe_user could set the date of the news record. The Time is not necessary, we use the extensions as a calendar. Thank you for your extension.

I tried somethling like this in FormFields.html :

cdaecke commented 5 years ago

Which field are you trying to use?

The field datetime can't be set in the form out of the box, since this field is set in the controller to the creation date of the record. If you want to use this field, you can use the SignalSlot createActionBeforeSave (see documentation) in order to overwrite the value with something you provide through the form.

bachblick commented 4 years ago

Hi Chris

Thank you for the reply. Unfortunately, this is to complicated for my TYPO3 expertise :-(

Is it a possibility that I pay you for this work and you add it to the extension?

I wrote this in ‘FormFields.html’

Können wir auf Deutsch kommunizieren?

Freundliche Grüsse Reto Schäublin

luna MULTIMEDIA Reto Schäublin

Bützenenweg 66b CH - 4450 Sissach +41 79 632 07 22 rs@luna-multimedia.info www.luna-multimedia.info

Am 26.10.2019 um 21:25 schrieb chris notifications@github.com:

Which field are you trying to use?

The field datetime can't be set in the form out of the box, since this field is set in the controller to the creation date of the record. If you want to use this field, you can use the SignalSlot createActionBeforeSave (see documentation https://github.com/cdaecke/md_newsfrontend#signal-slots) in order to overwrite the value with something you provide through the form.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cdaecke/md_newsfrontend/issues/17?email_source=notifications&email_token=ANRR7EOY26AY5UZ6HXRHWITQQSKSFA5CNFSM4JC4JTM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECKPETI#issuecomment-546632269, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANRR7EICD77RX6JYSEIRHDLQQSKSFANCNFSM4JC4JTMQ.

cdaecke commented 4 years ago

Hey Reto,

please find attached a small extension, which does the job. Just uncompress it and install it in your TYPO3 instance. After clearing the cache, the value from your above posted form field will be considered.

Let me know if this works for you.

Cheers chris

PS: No need for a payment. Maybe you can contribute in other places to Open Source :-)

cdaecke commented 4 years ago

Oops, wrong attachment. Use this one: md_newsfrontend_extended.zip

bachblick commented 4 years ago

Hey Chris

Thank you very much. I can’t save the record because of the error message for the date. See screenshot. I allready tried to change the dateformat in ModifyNews.php without success.

TYPO3 9.5.11

Best Reto

Am 07.11.2019 um 22:30 schrieb chris notifications@github.com:

Hey Reto,

please find attached a small extension, which does the job. Just uncompress it and install it in your TYPO3 instance. After clearing the cache, the value from your above posted form field will be considered.

Let me know if this works for you.

Cheers chris

PS: No need for a payment. Maybe you can contribute in other places to Open Source :-)

md_newsfrontend_extended.zip https://github.com/cdaecke/md_newsfrontend/files/3821779/md_newsfrontend_extended.zip — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cdaecke/md_newsfrontend/issues/17?email_source=notifications&email_token=ANRR7EJXFL4KYAUJDJXWMF3QSSCGLA5CNFSM4JC4JTM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDN4HOI#issuecomment-551273401, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANRR7EN65PRZ2K3RYASSMGTQSSCGLANCNFSM4JC4JTMQ.

cdaecke commented 4 years ago

Please post the screenshot or the error message :-)

bachblick commented 4 years ago

date-news date-news-2

cdaecke commented 4 years ago

Hm, the second message has nothing to do with the small extension I have sent. Does the warning disappear as soon as you disable the extension md_newsfrontend_extended?

And the first message: does it disappear as soon as you disable the extension md_newsfrontend_extended?

Are you sure, that you have installed this version of the extension?

bachblick commented 4 years ago

Yep, and to be sure, I installed it again with your last link. The error remains 'The date "..." was not recognized. It works, when I leave the datefield empty.

bachblick commented 4 years ago

extension-installed

Mayby I did something wrong with the installing? I loaded the folder with ftp in > typo3conf > ext and then activated it in the backend.

cdaecke commented 4 years ago

No, that sounds all good, nothing else to do.

For further debugging, please replace the file content of Classes/Slot/ModifyNews.php with the following code and paste the result here when you create a new news entry in the frontend.

<?php
namespace Mediadreams\MdNewsfrontendExtended\Slot;

use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
 *
 * Modify news record
 */
class ModifyNews
{
    /**
     * Use form value of field datetime for news record
     *
     * @param object $news The news object
     * @param object $obj The controller object
     * @return void
     */
    public function setDatetime($news, $obj) {
        $data = GeneralUtility::_GP('tx_mdnewsfrontend_newsfe');
        \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($data['newNews']);
        $datetime = \DateTime::createFromFormat('d.m.Y', $data['newNews']['datetime']);
        \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($datetime);

        if ($datetime instanceof \DateTime) {
            $news->setDatetime($datetime);
        }

        exit;
    }
}
bachblick commented 4 years ago

Thanks, but still the same error message. Maybe this can help? https://github.com/froemken/typo3-extbase-guide/blob/master/Documentation/Fluid/BestPractice/FormsWithDateTimeObjects.rst

date-news-3

cdaecke commented 4 years ago

Whoops, my fault, I am sorry! This can't work, because the validation of the data happens before the signal slot takes effect...

I will update and release a new version of the extension and let you know, as soon as it is done (hopefully this weekend).

cdaecke commented 4 years ago

Ok, the current master of the extension md_newsfrontend should now realy do the job. You don't need the little extension md_newsfrontend_extended anymore.

You are able to configure the format for datetime by changing the constant plugin.tx_mdnewsfrontend_newsfe.settings.formatDatetime. Default value is d.m.Y H:i which translates to DD.MM.YYYY HH:MM.

Are you able to test it and verify that it is working for you?

bachblick commented 4 years ago

Sorry, but I still have the same error. 'The date "17.11.2019" was not recognized for format "d.m.Y H:i"' What I did: Disable the extended extension Replace all files of the extension md_newsfrontend Write the Date form-group in 'FormFields.html' Clear all caches

cdaecke commented 4 years ago

Please change the constant „ plugin.tx_mdnewsfrontend_newsfe.settings.formatDatetime“ to „d.m.Y“ and clear the cache.

bachblick commented 4 years ago

PERFECT - thank you very much!

cdaecke commented 4 years ago

A new version of the extension is published.