2014-01-12 78 views
0

我是Joomla編程新手。我已經構建了一個插件,並且運行良好。我只有一點煩惱,整天都讓我發瘋。當你進入後端來配置插件時,選項被偏移180px的左邊距。我發現這是因爲這些選項被封裝在一個帶有應用了該邊距的style =「control-group」的div中。Joomla Plugin後端選項

爲了更好地理解下面是輸出的濃縮版的問題:

<div class="control-group"> 

<div class="control-label"> 
    <label id="jform_params_group_template_mapping-lbl" for="jform_params_group_template_mapping" class="hasTooltip" title="" data-original-title=""></label> 
</div> 

<div class="controls"> 
    //This is where my generated code is 
    <div class="control-group"> 
     <div class="control-label"> 
      <label>Uncategorised</label> 
     </div> 
     <div class="controls" style="float:right;margin-right:20%;"> 
     </div> 
    </div> 

    <div class="control-group"> 
     <div class="control-label"> 
      <label>Blog</label> 
     </div> 
     <div class="controls" style="float:right;margin-right:20%;"> 
     </div> 
    </div> 

    <div class="control-group"> 
     <div class="control-label"> 
      <label>TestingTemplate</label> 
     </div> 
     <div class="controls" style="float:right;margin-right:20%;"> 
     </div> 
    </div> 
</div> 

</div> 

正如你看到的,我的控制是所有控制內。我似乎無法找到帶有班級控制組的父級Div來自哪裏。我寧願我的生成的內容是有自己的控制,而不是sub div的。

請讓我知道您需要查看哪些代碼部分以幫助我確定此問題。我覺得它是XML清單的一部分,但是對於Joomla來說是新知道的。

清單文件的配置部分爲:

<config> 
    <fields name="params"> 
     <fieldset name="basic"> 
      <field type="fta.mapping" name="group_template_mapping" addfieldpath="/plugins/system/assigntemplatebycategory/fields" description="PLG_SYSTEM_TEMPLATE_ASSIGNER_GROUP_TEMPLATE_MAPPING_DESC" label="PLG_SYSTEM_TEMPLATE_ASSIGNER_GROUP_TEMPLATE_MAPPING_LABEL" default=""/> 
     </fieldset> 
    </fields> 
</config> 
+0

它似乎看着http://www.ostraining.com/blog/how-tos/development/getting-started-with-jform/,我不知何故創建了一個字段組,其中包含另一個字段組的字段與我所有的領域在裏面。不知道這是否解釋得更好或更糟。 –

+0

你可以請張貼XML清單?字段中的字段組不是一個好主意 –

+0

我是從另一個開發人員的工作開始的。看來在更多的閱讀之後,有兩種方法,getInput和getLabel在擴展jformfields時使用。以前的開發人員只擴展了getInput,並將子字段和子標籤的HTML作爲getInput的返回值。根據我閱讀的內容,我應該將其重新編碼爲兩個函數,一個用於GetLabels下的標籤,另一個用於getInput下的選項。請讓我知道,如果我正確理解這一點。 –

回答

0

配置文件的結構是正確的。但由於addfieldpath相當不尋常的是在田間水平通常定義,而不是單個字段即

<config> 
    <fields addfieldpath="/administrator/components/com_littlehelper/elements/" name="params"> 

我不知道這可能是一個問題。

最有可能的問題在於自定義字段。要進行測試,只需將字段類型更改爲text並查看是否顯示不需要的縮進。如果是這樣,那麼/plugins/system/assigntemplatebycategory/fields/fta.mapping.php中定義的自定義字段輸出應該包含一個額外的包裝器。

也嘗試將addfieldpath屬性移動到fields(並將其從field中刪除)。

+0

謝謝你讓我知道這些田地是在錯誤的地方。我感動了,但沒有幫助。我發現以前的開發者設置的方式是fta.mapping是一個自定義字段類型,它循環了大量信息並構建子控件。目標是爲每個類別獲得一個選項。我認爲這對我的小插件來說已經足夠了。 –