elgg添加网页方法

来源:互联网 发布:换手率软件怎么用 编辑:程序博客网 时间:2024/05/17 08:04

php系统添加hello world网页:

1.安装elgg。

2.创建文件start.php(路径为服务器根目录),内容为:

<?phpelgg_register_event_handler('init', 'system', 'hello_world_init');function hello_world_init() {}
这段代码是告诉elgg,它应该在系统初始化时,调用hello_world_init方法。

3.注册网页处理器:这步的任务是实现在用户请求网址https://elgg.example.com/hello时,处理相关业务。

更新start.php为:

<?phpelgg_register_event_handler('init', 'system', 'hello_world_init');function hello_world_init() {    elgg_register_page_handler('hello', 'hello_world_page_handler');}function hello_world_page_handler() {    echo elgg_view_resource('hello');}
注:当用户访问https://elgg.example.com/hello/*时,elgg_register_page_handler()告诉elgg调用方法hello_world_page_handler(),该方法渲染view视图为resources/hello

4.创建php网页,路径为views/default/resources/hello.php,内容为:

<?php$params = array(    'title' => 'Hello world!',    'content' => 'My first page!',    'filter' => '',);$body = elgg_view_layout('content', $params);echo elgg_view_page('Hello', $body);
该页向elgg_view_layout()方法传递titile,content,filter等网站页面的基本信息参数。

elgg_view_page()作为显示页面,检测所有控制信息,并完整展现整个网页。

5.此时,即实现了新建网页功能。

0 0
原创粉丝点击