【问题标题】:TYPO3 frontend editing for news records (ext:frontend_editing)TYPO3 前端编辑新闻记录 (ext:frontend_editing)
【发布时间】:2018-10-17 15:54:10
【问题描述】:

我正在尝试为新闻记录 (ext:news) 激活新的前端编辑 (ext:frontend_editing)。编辑部分运行良好,但我无法在前端添加新的新闻记录。

我按照manual 中的步骤操作,“自定义记录”部分出现了,但现在怎么办?有人能描述一下我需要传递给手册中描述的方法 wrapContentWithDropzone() 的值吗?

/**
 * @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;
 }

感谢任何帮助或朝着正确的方向前进!谢谢!

更新

我意识到,上面的代码在页面的最底部添加了一个拖放区。但是这个放置区只对“正常”内容元素有反应,而不是对我新添加的自定义元素有反应。 当我将方法“wrapContentWithDropzone()”的第一个值更改为“tx_news_domain_model_news”时,这个拖放区将创建一个新的新闻记录,无论哪个元素被删除...

所以我仍在寻找一种方法来激活自定义记录,以便最好在存储文件夹中添加新的新闻记录。

【问题讨论】:

    标签: typo3 tx-news


    【解决方案1】:

    您可以在模板中的任意位置使用它:

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

    但一定要在Plugin中设置storagePid,如果你使用settings.startingpoint。

    使用以下打字稿,您可以启用特定页面的新闻记录,您希望在其中插入新的新闻记录:

    plugin.tx_frontendediting{
        customRecords {
            10 {
                table = tx_news_domain_model_news
                pid = 142,154
            }
        }
    }
    

    【讨论】:

    • 你说得对,同时它就是这么简单,这是正确的答案。谢谢!
    【解决方案2】:

    经过一番调试,我自己找到了答案:

    不要使用方法“wrapContentWithDropzone()”,而是使用“wrapContentWithCustomDropzone()”。

    这是我的代码:

    排版:

    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
    }
    

    用户功能:

    <?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;
         }
    }
    

    这将在每个页面的最底部添加一个放置区,可以放置“tx_news_domain_model_news”类型的自定义元素。记录将存储在方法“addNewsDropZone()”中定义的页面上,在我的例子中是 uid=6 的页面。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多