【问题标题】:Joomla call specific function from component to moduleJoomla 从组件调用特定函数到模块
【发布时间】:2015-03-03 17:08:31
【问题描述】:

我只想调用组件中的特定函数。来自 com_rokgallery\lib\RokGallery\Model.file.php 中的 RokGallery 组件是我在模块中需要的 &createNew 函数。有谁知道我如何从我的模块中调用这些并给他们规范变量? 在第 31 行的 components\com_rokgallery\lib\RokGallery\Job\Processor\import.php 中,我认为我需要这些东西......

我希望有人可以帮助我....

问候,马文。

【问题讨论】:

    标签: database joomla


    【解决方案1】:

    理论上,您可以要求该文件并使用该类。 为此,您必须导入 rokgallery 库。

    $include_file = realpath(JPATH_ROOT . DS . 'components'. DS . 'com_rokgallery' . DS . 'include.php');
    
    $included_files = get_included_files();
    if (!in_array($include_file, $included_files) && ($libret = require_once($include_file)) !== 'JOOMLA_ROKGALLERY_LIB_INCLUDED') {
        JError::raiseWarning(100, 'RokGallery: ' . implode('<br /> - ', $loaderrors));
        return;
    }
    

    一旦你可以使用静态方法createNew

    $file = RokGallery_Model_File::createNew($filename, $filepath);
    

    【讨论】:

    • 嘿,谢谢.. 嗯,我在开发模块/组件方面相对较新,我应该把这 2 个 sn-ps 放在哪里?都在 der mod_XXX/helper.php 或 mod_XXX/module.php 谢谢你的回答...
    • 如果你在mod_xxx/xxx.php的第一部分在定义('_JEXEC')之后使用它或者死掉;那么你可以使用 RokGallery_Model_File::createNew();无处不在。
    猜你喜欢
    • 2013-01-15
    • 2011-08-11
    • 2011-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-29
    • 1970-01-01
    • 2016-01-15
    相关资源
    最近更新 更多