1

I am trying to activate the new frontend editing (ext:frontend_editing) for news records (ext:news). The editing part is working well, but I am failing to add new news records in the frontend.

I am following the steps in the manual and the "custom records" part appears, but what now? Can someone describe what values I need to pass to the method wrapContentWithDropzone(), which is described in the manual?

/**
 * @param string $content Empty string (no content to process)
 * @param array $conf TypoScript configuration
 * @return string $content
 */
 public function wrapWithDropZone($content, $conf)
 {
      if (GeneralUtility::_GET('frontend_editing') && GeneralUtility::makeInstance(AccessService::class)->isEnabled()) {
           $wrapperService = GeneralUtility::makeInstance(ContentEditableWrapperService::class);

           $content = $wrapperService->wrapContentWithDropzone(
                'tt_content', // table name
                0, // page uid, pid
                $content,
                0 // colPos
           );
      }

      return $content;
 }

Appreciate any help or push into the right direction! Thanks!

UPDATE

I realized, that the code above adds a drop zone at the very bottom of a page. But this drop zone only reacts on "normal" content elements, but not on my newly added custom element. When I change the first value of the method "wrapContentWithDropzone()" to "tx_news_domain_model_news", this drop zone will create a new news record, regardless which element was dropped...

So I am still looking for a way, to activate the custom record in order to add new news records preferably on a storage folder.

chris
  • 2,109
  • 2
  • 23
  • 33

2 Answers2

1

After some debugging I found the answer myself:

Do not use method "wrapContentWithDropzone()" but "wrapContentWithCustomDropzone()".

Here is my code:

Typoscript:

plugin.tx_frontendediting {
    customRecords {
        10 {
            table = tx_news_domain_model_news
            pid = 6
        }
    }
}

page = PAGE
page.1001 = USER
page.1001 {
    userFunc = Vendor\Extension\UserFunc\FrontendEditing->addNewsDropZone
}

User function:

<?php
namespace Vendor\Extension\UserFunc;

use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\FrontendEditing\Service\AccessService;
use TYPO3\CMS\FrontendEditing\Service\ContentEditableWrapperService;

class FrontendEditing {

    /**
     * @param string $content Empty string (no content to process)
     * @param array $conf TypoScript configuration
     * @return string $content
     */
    public function addNewsDropZone($content, $conf)
    {
        if (GeneralUtility::_GET('frontend_editing') && GeneralUtility::makeInstance(AccessService::class)->isEnabled()) {
            $wrapperService = GeneralUtility::makeInstance(ContentEditableWrapperService::class);

            $content = $wrapperService->wrapContentWithCustomDropzone(
                'tx_news_domain_model_news', // table name of the record you want to create
                $content,
                // additional fields if needed
                [
                    //'title' => 'default title'
                ],
                6 // page uid of the page where you want to store the news records
            );
        }

        return $content;
     }
}

This will add a drop zone at the very bottom of every page where the custom element of the type "tx_news_domain_model_news" can be dropped. The records will be stored on the page which is defined in the method "addNewsDropZone()", in my case the page with the uid=6.

chris
  • 2,109
  • 2
  • 23
  • 33
1

you could just use this wherever you want in your template:

<core:customDropZone tables="{0:'tx_news_domain_model_news'}" pageUid="{settings.startingpoint}"></core:customDropZone>

But be sure to set the storagePid in Plugin, if you use settings.startingpoint.

With the following typoscript, you enable the news records for the specific pages, where you want to insert new news records:

plugin.tx_frontendediting{
    customRecords {
        10 {
            table = tx_news_domain_model_news
            pid = 142,154
        }
    }
}
Tobias Pf
  • 26
  • 1
  • You are absolutely right, in the meantime it is that easy and this is the correct answer. Thanks! – chris Nov 25 '19 at 14:36