Discuz showDialog弹出对话框

2021-03-20 726 0条评论

image.png
实例1 : get 方式弹出对话框

在Discuz的大部分的帖子页面,都有一个”回复“ 连接,如下图:


点击回复,就会有一个弹出对话框:


这里,就用到了 ShowDialog(), 其对应的代码为:

<a class="fastre" href="forum.php?mod=post&action=reply&fid=2&tid=55&reppost=86&extra=page%3D1%26filter%3Dsortid%26sortid%3D1&page=1">回复</a>


可以看到,这里采用了get方式。URL直接通过showWindow的第二个参数传输。




实例2: post 方式弹出对话框
在forum_moderate.js中使用到了通过post方式弹出对话框。当在页面中“推送”数据时使用到了这段代码。



showWindow('mods', 'modactions', 'post');



其中modactions必须是在在页面中出现的一个表单的form ID。


实例3:
在下面的例子中,点击“弹窗测试”将会弹出一个窗口。

其中,对应的代码:

<a class="push xi2" href="javascript:;">弹窗测试</a>

在source/module/forum/下添加forum_mypopuptest.php文件,作为相应函数。实现的功能非常简单,就是查询一下数据库。

<?php



if(!defined('IN_DISCUZ')) {

exit('Access Denied');

}

define('NOROBOT', TRUE);


$data = array('html'=>'', 'data'=>'');

$query = DB::query('SELECT * FROM '.DB::table('common_admincp_group')." ");

while($value = DB::fetch($query)) {

$data[] = $value;

}


include template('forum/test_popup');

dexit();


?>


test_popup.htm就是简单的将数据输出来

<!--{template common/header}-->

<!--{if empty($_GET['infloat'])}-->

<divid="ct"class="wp cl" >

<divclass="mn" >

<divclass="bm bw0">

<!--{/if}-->

<br/>

test popup

<tablesummary="{lang stats_forum_stat_log}"class="dt bm mtw mbw">

<tr>

<td></td><thwidth="200">{lang stats_date}</th><td></td><td></td>

</tr>

<!--{loop $data $item}-->

<tr>

<td></td><td>$item['cpgroupid']</td><td>$item['cpgroupname']</td><td></td>

</tr>

<!--{/loop}-->

</table>

</br >


<!--{if empty($_GET['infloat'])}-->

</div>

</div >

</div >

<!--{/if}-->

<!--{template common/footer}-->


最后,还需要将“mypopuptest” 添加到forum.php的$modarray数组中,否则该页面将无法被相应到。



注意,如果弹出窗口中还有按钮或者连接,当用户点击之后,内容又将会在大窗口中显示,不会继续局限在弹出窗口中显示。如果要在弹出窗口中显示,还是需要继续做类似的处理。

实例4:
这里演示一个复杂一点的例子,以post方式传递的二级弹窗。
修改上述test_popup.htm为:

<!--{template common/header}-->

<!--{if empty($_GET['infloat'])}-->

<divid="ct"class="wp cl" >

<divclass="mn" >

<divclass="bm bw0">

<!--{/if}-->

<br/>

test popup

<tablesummary="{lang stats_forum_stat_log}"class="dt bm mtw mbw">

<tr>

<td></td><thwidth="200">{lang stats_date}</th><td></td><td></td>

</tr>

<!--{loop $data $item}-->

<tr>

<td></td><td>$item['cpgroupid']</td><td>$item['cpgroupname']</td><td></td>

</tr>

<!--{/loop}-->

</table>

</br >


<formmethod="post"autocomplete="off"name="searchform"id="searhsort"class="bbs bm_c pns mfm cl"action="forum.php?mod=mypopuptest2" >

<div >

userName:<inputtype="text"name="userName"size="15"class="px vm"value="" >


<buttontype="submit"class="pn pnc"name="searchsortsubmit"onclick="showWindow('mods','searchform','post')"><em>Search</em></button>

</div >

</form >


<!--{if empty($_GET['infloat'])}-->

</div>

</div >

</div >

<!--{/if}-->

<!--{template common/footer}-->



添加forum_mypopuptest2.php,其中直接跳转到test_popup2.html

<?php

if(!defined('IN_DISCUZ')) {

exit('Access Denied');

}

define('NOROBOT', TRUE);


include template('forum/test_popup2');

dexit();

?>

test_popup2.html也很简单

<!--{template common/header}-->

<!--{if empty($_GET['infloat'])}-->

<divid="ct"class="wp cl"]] >

<divclass="mn"]] >

<divclass="bm bw0"]]>

<!--{/if}-->


test popup 2


<!--{if empty($_GET['infloat'])}-->

</div]]>

</div]] >

</div]] >

<!--{/if}-->

<!--{template common/footer}-->


文章版权及转载声明

本文作者:符文浩 网址:http://blog.fuwenhao.com/post/403.html 发布于 2021-03-20
文章转载或复制请以超链接形式并注明出处。

发表评论

快捷回复:

评论列表 (暂无评论,726人围观)参与讨论

还没有评论,来说两句吧...

取消
微信二维码
微信二维码
支付宝二维码