新闻记录的 TYPO3 前端编辑 (ext:frontend_editing)
TYPO3 frontend editing for news records (ext:frontend_editing)
我正在尝试为新闻记录 (ext:news) 激活新的前端编辑 (ext:frontend_editing)。编辑部分用的很好,但是我在前端添加新的新闻记录失败。
我正在按照 manual 中的步骤进行操作,然后 "custom records" 部分出现了,但现在怎么办?有人可以描述我需要将哪些值传递给手册中描述的 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;
}
感谢任何帮助或推动正确的方向!谢谢!
更新
我意识到,上面的代码在页面的最底部添加了一个拖放区。但是这个拖放区只对 "normal" 内容元素有反应,对我新添加的自定义元素没有反应。
当我将方法 "wrapContentWithDropzone()" 的第一个值更改为 "tx_news_domain_model_news" 时,此拖放区将创建一个新的新闻记录,无论拖放了哪个元素...
所以我还在寻找一种方法,激活自定义记录,以便最好在存储文件夹中添加新的新闻记录。
经过一些调试我自己找到了答案:
不要使用方法 "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.
的页面
您可以在模板中的任意位置使用它:
<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
}
}
}
我正在尝试为新闻记录 (ext:news) 激活新的前端编辑 (ext:frontend_editing)。编辑部分用的很好,但是我在前端添加新的新闻记录失败。
我正在按照 manual 中的步骤进行操作,然后 "custom records" 部分出现了,但现在怎么办?有人可以描述我需要将哪些值传递给手册中描述的 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;
}
感谢任何帮助或推动正确的方向!谢谢!
更新
我意识到,上面的代码在页面的最底部添加了一个拖放区。但是这个拖放区只对 "normal" 内容元素有反应,对我新添加的自定义元素没有反应。 当我将方法 "wrapContentWithDropzone()" 的第一个值更改为 "tx_news_domain_model_news" 时,此拖放区将创建一个新的新闻记录,无论拖放了哪个元素...
所以我还在寻找一种方法,激活自定义记录,以便最好在存储文件夹中添加新的新闻记录。
经过一些调试我自己找到了答案:
不要使用方法 "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.
的页面您可以在模板中的任意位置使用它:
<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
}
}
}