如何在自定义字段中获取Joomla模块标题?

时间:2015-10-20 18:23:46

标签: joomla

我正在Joomla中创建一个自定义字段。我有这段代码:

class JFormFieldEmbed extends JFormField {
    protected $type = 'Embed';
    public function getInput() {
        $out='';
        $out.='<pre>'.print_r($this->form,true).'</pre>';
        return $out;
    }
}

我在输出$ form-&gt;中看到包含标题但是受保护对象的数据。

如何在自定义字段中获取Joomla模块标题?

更新:

现在我用JavaScript解决方案:

class JFormFieldEmbed extends JFormField {
    protected $type = 'Embed';
    public function getInput() {
        $script1=htmlentities('<script type="text/javascript" src="'.JURI::root().'modules/mod_mydodule/js/script.js" data-title="');
        $script2=htmlentities('"></script>');
return<<<EOD
<div id="embedmymodule"></div>
<script type="text/javascript">
    jQuery(function($){
        $("#embedmymodule").html('$script1'+encodeURIComponent( $('[name=\"jform[title]\"]').val() )+'$script2');
    });
</script>
EOD;
    }
}

2 个答案:

答案 0 :(得分:0)

此代码将输出模块标题:

$module->title

答案 1 :(得分:0)

在Joomla的源文件中找到答案:

public UC1()
        {
            InitializeComponent();            
            this.DataContext = App.ViewModel.TestViewModel;
        }

 private void UC1_Unloaded(object sender, RoutedEventArgs e)
        {
            this.DataContext = null;
        }


public UC2()
        {
            InitializeComponent();            
            this.DataContext = App.ViewModel.TestViewModel;
        }

 private void UC2_Unloaded(object sender, RoutedEventArgs e)
        {
            this.DataContext = null;
        }