2014-01-17 75 views
1

我已經創建的Joomla模塊,並在後臺參數配置添加自定義字段類型,使用.xml文件是這樣的:的Joomla 3.0-GET模塊ID

<fields name="params"> 
    <fieldset 
     addfieldpath="/modules/<module_name>/fields" name="basic"> 
      <field name="articles" type="articles" label="label" /> 

. 
. 
. 
</fields> 

即工作相當罰款,但有問題遺留下來:我如何訪問模塊的ID內的自定義字段類,當調用創建字段的HTML?

謝謝!

UPDATE

我挖深一點在於發現JModuleHelper::getModule($type, $name)方法,它返回任一給定$type的第一模塊如果沒有指定$name,或具有$name給定$type的模塊, 但是,因爲可以創建具有相同名稱的模塊,所以這種方法有點難看。

+0

$應用= JFactory :: getApplication(); $ module_id = $ app-> input-> getInt('id'); –

回答

1

該解決方案隱藏在URL中,並在Joomla的情況下,在JInput。完整,更詳細的解釋是here(一底部),但在短:

一個模塊編輯屏幕的URL:

index.php?option=com_modules&view=module&layout=edit&id=87 

將是太容易了,用這個...