我有一个窗体,里面有joomla2.5编辑器。我想在Iframe joomla2.5 Modal Box中显示Joomla2.5编辑器的内容。我使用joomla编辑器
<?php
$editor =& JFactory::getEditor();
echo $editor->display( 'body', '', '400', '150', '20', '20', false, $params );
?>此页位于视图文件夹中。我使用像window.parent.document.getElementById('body').value or window.parent.jInsertEditorText(tag, this.body);这样的js文件中的代码,它包含在js文件中。当我尝试发出警报时,警报显示为空。如何在js文件中修复这个问题。如果有人知道这件事,请回复。我需要你的手。谢谢
发布于 2012-03-14 21:08:49
我在这里写答案,因为注释不适合显示代码
Joomla模式功能可以很好地显示来自组件的链接,但不允许我们在页面上打开给定的元素。因此,您需要编写自己的代码,首先不要覆盖Joomla的核心,否则您所做的所有修改将在下次升级时被覆盖。因此,假设您考虑到这一点:
1-首先要做的是,为您的自定义模式窗口添加javascript代码。您需要将文本容器div id或classname传递给以下代码:
<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=”部分,因为它将被前面的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-13 21:51:37
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 );
?>发布于 2013-05-09 15:26:32
请在锚标签中包含class="modal“。
https://stackoverflow.com/questions/9684906
复制相似问题