FriendsOfTYPO3 / frontend_editing

TYPO3 CMS Frontend Editing
https://friendsoftypo3.github.io/frontend_editing/
102 stars 38 forks source link

New content elements on blank page #301

Closed xima-wla closed 3 years ago

xima-wla commented 6 years ago

Hi!

I cannot create new content elements on a blank page. Drag & drop is not working. I can just drag new content elements on a page where content elements already exist.

TYPO3 8.7.19 frontend_editing 1.3.7

cdaecke commented 5 years ago

I added a new drop zone like discribed in the manual. This new drop zone is available at the very bottom of all pages.

My code looks like this:

Typoscript:

page = PAGE
page.1001 = USER
page.1001 {
    userFunc = Your\NameSpace\UserFunc\FrontendEditing->wrapWithDropZone
}

User function

<?php
namespace Your\NameSpace\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 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 of the record you want to create
                0, // page uid where to store the new record (if set to 0 it will use the current page)
                $content
            );
        }

        return $content;
     }
}

Hope this helps :-)

MattiasNilsson commented 3 years ago

As this now have been documented and answered, closing issue.