【问题标题】:Joomla 3.0—get module id inside custom formJoomla 3.0——在自定义表单中获取模块 ID
【发布时间】:2014-01-17 09:37:34
【问题描述】:

我已经创建了 Joomla 模块,并在后端的参数配置中添加了一个自定义字段类型,使用这样的 .xml 文件:

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

.
.
.
</fields>

这工作得很好,但还有一个问题:当被调用以创建字段 html 时,如何访问自定义字段类中的 模块的 id

提前谢谢!

更新

我挖掘得更深一点,找到了JModuleHelper::getModule($type, $name) 方法,如果没有指定$name,它返回给定$type 的第一个模块,或者给定$type 的模块具有@987654326 @, 但是 因为可以创建具有相同名称的模块,所以这种方法有点难看。

【问题讨论】:

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

标签: joomla3.0 joomla-module


【解决方案1】:

解决方案隐藏在 URL 中,如果是 Joomla,则隐藏在 JInput 中。完整和更详细的解释是here(底部),但简而言之:

模块编辑屏幕的 URL:

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

用这个太容易了……

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-05-23
    • 2015-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-10
    • 1970-01-01
    相关资源
    最近更新 更多