2

我有一个表单,其中有 joomla2.5 编辑器。我想在 Iframe Joomla2.5 模态框中显示那个 joomla2.5 编辑器的内容。我使用 joomla 编辑器

<?php 
  $editor =& JFactory::getEditor(); 
  echo $editor->display( 'body', '', '400', '150', '20', '20', false, $params );
?>

此页面在视图文件夹中。我使用 js 文件中的代码,例如window.parent.document.getElementById('body').value or window.parent.jInsertEditorText(tag, this.body);它包含在 js 文件中。当我尝试提醒时,提醒显示为空。如何在 js 文件中解决此问题。如果有人知道它,请回复它。我需要你的手。谢谢

4

3 回答 3

2

我把答案写在这里,因为注释不好显示代码

Joomla 模态功能可以很好地显示来自组件的链接,但不允许我们打开页面上的给定元素。因此您需要编写自己的代码,首先不要覆盖 Joomla 的核心,否则您所做的所有修改将在下次升级时被覆盖。因此,假设您考虑到这一点:

1- 首先要做的,为您的自定义模式窗口添加 javascript 代码。您需要将文本容器 div id 或类名传递给以下代码:

<script type="text/javascript">
$(document).ready(function(){
    // Main parameters:
    // Modify texteditor-id with the id or classname on your text div. For a classname use '.' instead of '#'
    var HTMLContent = $("#texteditor-id").html();

    var width = 600; 
    var height = 250;

    $('#button').click(function(){
            // transparent background
            // we create a new div, with two attributes
            var bgdiv = $('<div>').attr({
                                    className: 'bgtransparent',
                                    id: 'bgtransparent'
                                    });

            // add the new div to the page
            $('body').append(bgdiv);

            // get the widht and height of the main window
            var wscr = $(window).width();
            var hscr = $(window).height();

            // set the background dimensions
            $('#bgtransparent').css("width", wscr);
            $('#bgtransparent').css("height", hscr);


            // modal window
            // create other div for the modal window and two attributes
            var moddiv = $('<div>').attr({
                                    className: 'bgmodal',
                                    id: 'bgmodal'
                                    });     

            // add div to the page
            $('body').append(moddiv);

            // add HTML content to the modal window
            $('#bgmodal').append(HTMLContent);

            // resize for center adjustment
            $(window).resize();
    });

    $(window).resize(function(){
            // explorer window dimensions
            var wscr = $(window).width();
            var hscr = $(window).height();

            // setting background dimensions
            $('#bgtransparent').css("width", wscr);
            $('#bgtransparent').css("height", hscr);

            // setting modal window size
            $('#bgmodal').css("width", ancho+'px');
            $('#bgmodal').css("height", alto+'px');

            // getting modal window size
            var wcnt = $('#bgmodal').width();
            var hcnt = $('#bgmodal').height();

            // get central position
            var mleft = ( wscr - wcnt ) / 2;
            var mtop = ( hscr - hcnt ) / 2;

            // setting modal window centered
            $('#bgmodal').css("left", mleft+'px');
            $('#bgmodal').css("top", mtop+'px');
    });

 });

 function closeModal(){
    // remove created divs
    $('#bgmodal').remove();
    $('#bgtransparent').remove();
}
</script>

2-您的预览链接必须看起来像这样,最重要的部分是 id="button" 部分,因为它将用于由前面的 jquery 代码识别:

<input type="button" id="button" value="Preview" />

3-将以下代码添加到您的CSS

.bgtransparent{
    position:fixed;
    left:0;
    top:0;
    background-color:#000;
    opacity:0.6;
    filter:alpha(opacity=60);
}

.bgmodal{
    position:fixed; 
    font-family:arial;
    font-size:1em;
    border:0.05em solid black;
    overflow:auto;
    background-color:#fff;
}

这基本上就是你需要做的。希望有帮助!

于 2012-03-14T13:08:49.030 回答
0

请在锚标记中包含 class="modal"。

于 2013-05-09T07:26:32.183 回答
0

Joomla 有一个内置的方式来显示模态框:

首先你需要做的是让 Joomla 加载模态库:

 <?php JHTML::_('behavior.modal'); ?>

这是打开模态窗口的代码:

<a rel="{handler: 'iframe', size: {x: 750, y: 600}}" href="url_to_modal_editor" target="_blank"> Open Modal Editor</a>

这将进入链接的 href 页面(模态编辑器的页面),比如说 editor.p:

<?php 
  $editor =& JFactory::getEditor(); 
  echo $editor->display( 'body', '', '400', '150', '20', '20', false, $params );  
?>
于 2012-03-13T13:51:37.327 回答