开发实例:模块内容用户投稿后,通知到指定的账号(可多个账号)
后台设置效果界面:
例子以Demo模块为例,其他模块请自己修改目录名称。
1、新建配置控制器文件:dayrui/App/Demo/Controllers/Admin/Param.php
_Module_Param(); } }
2、新建控制器模板文件:dayrui/App/Demo/Views/param.html
{template "header.html"}{template "footer.html"}
3、访问这个页面,并设置数据,效果见首图
admin.php?s=demo&c=param&m=index
4、模块钩子开发,写入程序逻辑代码:dayrui/App/Demo/Config/Hooks.php
module['setting']['param']['notice'][$name]['username']) && \Phpcmf\Service::C()->module['setting']['param']['notice'][$name]['username']) { $var = dr_array2array($data[1], $data[0]); $fields = \Phpcmf\Service::C()->module['field']; $fields['inputtime'] = ['fieldtype' => 'Date']; $fields['updatetime'] = ['fieldtype' => 'Date']; $var = \Phpcmf\Service::L('Field')->format_value($fields, $var, 1); $arr = explode(',', \Phpcmf\Service::C()->module['setting']['param']['notice'][$name]['username']); foreach ($arr as $autor) { $user = dr_member_username_info($autor); if (!$user) { log_message('error', '自定义钩子:已开启通知提醒,但通知人['.$autor.']有误'); } else { \Phpcmf\Service::L('Notice')->send_notice_user( 'my_send_'.APP_DIR.'_'.$name, $user['id'], $var, \Phpcmf\Service::C()->module['setting']['param']['notice'][$name], 1 // 1立即发送 ); } } } }