2017-11-16 9 views
0

私はTYPO3(最初のプロジェクト)を初めて使いました。カラーピッカーでカスタム要素を作成する際のいくつかの問題があります。このプロジェクトでは、すでにいくつかの要素を作成していますが、バックエンド入力にはあらかじめ決められたフィールドしか使用していません。私が次に必要とする要素については、ユーザーが色を選択する必要があります。私は適切な既存の要素を発見していない。私のセットアップは動作しませんTCA/Overrides/tt_content.phpファイルにあり、このようになります。TYPO3カスタム要素colorpicker

$GLOBALS['TCA']['tt_content']['item_0']=array();    
$GLOBALS['TCA']['tt_content']['item_0']['label']='Color'; 
$GLOBALS['TCA']['tt_content']['item_0']['config']=array(); 
$GLOBALS['TCA']['tt_content']['item_0']['config']['type']='input'; 
$GLOBALS['TCA']['tt_content']['item_0']['config']['renderType']='colorpicker'; 
$GLOBALS['TCA']['tt_content']['item_0']['config']['size']=10; 

$GLOBALS['TCA']['tt_content']['types']['wo_mitem'] = array(
    'showitem' => '--palette--;LLL:EXT:cms/locallang_ttc.xlf:palette.general;general, 
     header;Title, 
     subheader;Background, 
     header_link;Target, 
     item_0;Color, 
     bodytext;Text;;richtext:rte_transform[flag=rte_enabled|mode=ts_css] 
     '); 

item_0の場合はColorPickerを作成しようとしたが、動作するようには思えません。別のファイルで別のものが必要ですか?自分のフィールドを定義するために追加した最初の数行。これを行うより良い方法はありますか?

私のカスタム拡張機能の他のファイルは他のすべてのカスタム要素が正常に動作しているため、動作します。唯一の違いは、新しいもので色を選択する方法が必要であるということです。ただ、ここで明確な外観のための

他のファイル

SETUP.TXT:

lib.contentElement { 
    templateRootPaths { 
    100 = EXT:wostyle/Resources/Private/Template 
    } 
} 
tt_content { 
    wo_mitem < lib.contentElement 
    wo_mitem { 
     templateName = MItem 
    } 
} 

tt_content.php

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(
    array(
     'WO_Item (ItemBox, Text only)', 
     'wo_mitem', 
     'content-image' 
    ), 
    'CType', 
    'wostyle' 
); 

$GLOBALS['TCA']['tt_content']['item_0']=array();    
$GLOBALS['TCA']['tt_content']['item_0']['label']='Farbe'; 
$GLOBALS['TCA']['tt_content']['item_0']['config']=array(); 
$GLOBALS['TCA']['tt_content']['item_0']['config']['type']='input'; 
$GLOBALS['TCA']['tt_content']['item_0']['config']['renderType']='colorpicker'; 
$GLOBALS['TCA']['tt_content']['item_0']['config']['size']=10; 

$GLOBALS['TCA']['tt_content']['types']['wo_mitem'] = array(
      'showitem' => '--palette--;LLL:EXT:cms/locallang_ttc.xlf:palette.general;general, 
      header;Bezeichnung, 
      subheader;Chemische Bezeichnung, 
      header_link;Zielseite, 
      item_0;Farbe, 
      bodytext;Text;;richtext:rte_transform[flag=rte_enabled|mode=ts_css] 
      '); 

typo.ts

mod.wizards.newContentElement.wizardItems.wo_extra { 
    header = WO Elemente 
    after = common 
    elements { 
    wo_mitem { 
     iconIdentifier = content-image 
     title = WO_Item (ItemBox, Text only) 
     description = Ein Produktfeld mit Text 
     tt_content_defValues { 
      CType = wo_mitem 
     } 
     } 
    } 
    show := addToList(wo_mitem) 
} 

MItem。 html

<div class="item-text"> 
    <f:link.typolink parameter="{data.header_link}"> 
     <div class="item-front"> 
      <f:if condition="{data.subheader}!=''"> 
      <f:then> 
      <div class="item-bg"> 
       <f:format.html>{data.subheader}</f:format.html> 
      </div> 
      </f:then> 
      </f:if> 
      <div class="item-title"> 
       <f:format.html>{data.header}</f:format.html> 
      </div> 
     </div> 
     <div class="item-back"> 
      <f:format.html>{data.bodytext}</f:format.html> 
     </div> 
    </f:link.typolink> 
</div> 
<f:debug>{data}</f:debug> 

編集:私はTYPO3 8.7.8

答えて

1

を使用し、私はあなたのコード全体をチェックしませんでしたが、私は、フィールド上の作業用カラーピッカーを持っている... あなたは近いですが、ポップエラーすぐにアップウィザードにrefferenceが欠落している隣のあなたの項目が['columns'] ...

$GLOBALS['TCA']['tt_content']['columns']['item_0']=array(); 

下に置かれるべきであるということです! (あなたがはるかに構造を示した角括弧付きの注釈を採用すべきでは)

これはConfiguration/TCA/Overrides/tt_content.phpに格納する必要があります:

<?php 

/*************** 
* Modify the tt_content TCA 
*/ 
$tca = [ 
    'columns' => [ 
     'item_0' => [ 
      'label' => 'Color', 
      'config' => [ 
       'type' => 'input', 
       'size' => 10, 
       'eval' => 'trim', 
       'default' => '#ffffff', 
       'wizards' => [ 
        'colorChoice' => [ 
         'type' => 'colorbox', 
         'title' => 'LLL:EXT:lang/locallang_wizards:colorpicker_title', 
         'module' => [ 
          'name' => 'wizard_colorpicker' 
         ], 
         'dim' => '20x20', 
         'JSopenParams' => 'height=600,width=380,status=0,menubar=0,scrollbars=1', 
        ], 
       ], 
      ], 
     ], 
    ], 
]; 
$GLOBALS['TCA']['tt_content'] = array_replace_recursive($GLOBALS['TCA']['tt_content'], $tca); 
(既存のフィールドを上書きする場合、そうでなければ、要素のために専用のコードを持っています)
+0

大変お世話になりました。 "列"は欠落しており、表自体のitem_0フィールドもありません。 :) – Nyxeen

0

webManとインターネット検索の助けを借りて、私は少し自分のコードを採用することができました。 私はコンテンツ

CREATE TABLE tt_content (
    item_0 varchar(10) DEFAULT '' NOT NULL, 
); 

でファイル「ext_tables.sql」を追加され、TCAでtt_content.phpを変更/上書きする:

$temporaryColumns = Array(
    "item_0" => Array(
     'label' => 'Color', 
     'config' => Array(
      'type' => 'input', 
      'renderType' => 'colorpicker', 
      'size' => 10 
     ) 
    ) 
); 
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('tt_content',$temporaryColumns); 

$GLOBALS['TCA']['tt_content']['types']['wo_mitem'] = array(
      'showitem' => '--palette--;LLL:EXT:cms/locallang_ttc.xlf:palette.general;general, 
      header;Bezeichnung, 
      subheader;Chemische Bezeichnung, 
      header_link;Zielseite, 
      item_0;Farbe, 
      bodytext;Text;;richtext:rte_transform[flag=rte_enabled|mode=ts_css] 
      '); 

webMansに比較して不足しているビューのものがまだありますコードが、少なくともこれは私が持っている最初の作業バージョンですので、私は私の質問が答えているので、それを示すと思った:)。

関連する問題