Tuy nhiên, để đơn giản có thể làm như sau: tạo 2 files
custom/include/SugarFields/Fields/Text/SugarFieldText.php
defaultConfig['cleanup_on_startup']=true; $tiny->buttonConfigs['default']['buttonConfig'] = "bold,italic,underline,strikethrough,bullist,numlist,forecolor,backcolor,link,unlink,help,code"; $tiny->buttonConfigs['default']['buttonConfig2'] = "formatselect,fontselect,fontsizeselect"; $tiny->buttonConfigs['default']['buttonConfig3'] = ""; $tiny->defaultConfig['height'] = ($vardef['rows'] * 30); $ed = $tiny->getInstance($vardef['name']); $displayParams['ed'] = $ed; parent::setup($parentFieldArray, $vardef, $displayParams, $tabindex, $twopass); } function getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex){ $vardef['value'] = $this->getVardefValue($vardef); $this->setup($parentFieldArray, $vardef, $displayParams, $tabindex); return $this->fetch($this->findTemplate('DetailView')); } function getVardefValue($vardef){ if(empty($vardef['value'])){ if(!empty($vardef['default'])) return from_html($vardef['default']); elseif(!empty($vardef['default_value'])) return from_html($vardef['default_value']); } else { return from_html($vardef['value']); } } }custom/include/SugarFields/Fields/Text/EditView.tpl
{literal}<script language="Javascript" type="text/javascript"> if(typeof(tinyMCE) == 'undefined') document.write("<scr"+"ipt type=\"text/javascript\" src=\"include/javascript/tiny_mce/tiny_mce.js\"></scr"+"ipt>"); </script>{/literal} {if empty({{sugarvar key='value' string=true}})} {assign var="value" value={{sugarvar key='default_value' string=true}} } {else} {assign var="value" value={{sugarvar key='value' string=true}} } {/if} {{if $displayParams.maxlength}} {literal} {{$tiny}} {/literal}<textarea cols="{{$displayParams.cols|default:60}}" id="{{sugarvar key='name'}}" maxlength="{{$displayParams.maxlength}}" name="{{sugarvar key='name'}}" rows="{{$displayParams.rows|default:4}}" tabindex="{{$tabindex}}" title="{{$vardef.help}}" {{$displayparams.field}}="">{$value}</textarea> {{else}} {literal} {{$tiny}} {/literal}<textarea cols="{{$displayParams.cols|default:80}}" id="{{sugarvar key='name'}}" name="{{sugarvar key='name'}}" rows="{{$displayParams.rows|default:4}}" tabindex="{{$tabindex}}" title="{{$vardef.help}}" {{$displayparams.field}}="">{$value}</textarea> {{/if}} {literal} <script language="Javascript" type="text/javascript"> tinyMCE.execCommand('mceAddControl',false,"{/literal}{{sugarvar key='name'}}{literal}"); </script> {/literal}
Ngoài ra, có thể tạo thêm 1 file
custom/include/SugarFields/Fields/Text/DetailView.tpl
{{sugarvar key='value|htmlparser'}} {{if !empty($displayParams.enableConnectors)}} {{sugarvar_connector view='DetailView'}} {{/if}}
Sau khi thực hiện xong vào Admin - "Repair and Rebuild Module" để cập nhật.
No comments:
Post a Comment