2017-11-16 2 views
0

저는 TYPO3 (첫 번째 프로젝트)을 처음 사용하고 colorpicker가 포함 된 사용자 지정 요소 만들기에 대한 몇 가지 이해 문제가 있습니다. 이 프로젝트에서 저는 이미 몇 가지 요소를 만들었지 만, 백엔드 입력을 위해 미리 지정된 필드 만 사용합니다. 다음에 필요한 요소의 경우 사용자가 색상을 선택해야합니다. 나는 맞는 기존 요소를 찾지 못했습니다. 작동하지 않는 설정은 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를 만들려고했지만 작동하지 않는 것 같습니다. 다른 파일에서 다른 것을 필요합니까? 내 필드를 정의하기 위해 추가 한 처음 몇 줄. 이 작업을 수행하는 더 좋은 방법이 있습니까?

내 모든 맞춤 구성 요소가 정상적으로 작동하므로 내 맞춤 확장 작업의 다른 모든 파일이 작동합니다. 유일한 차이점은 새로 말한 것에서 색상을 선택하는 방법이 필요하다는 것입니다.

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

: 그냥 여기에 명확하게 보이는 다른 파일

SETUP.TXT에 대한

. 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); 
(기존 필드를 오버라이드 (override) 할 경우에, 그렇지 않으면 당신은 요소의 전용 코드가 있습니다)
+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 비교에서 누락보기 일들이 여전히있다 코드하지만 적어도 이것은 내가 가지고있는 첫 번째 작업 버전입니다 그래서 나는 내 질문에 대답 이후 그것을 보여 주 생각 :).