wuzhicms 模块开发
首先,模块开发需要了解五指cms的目录结构:
然后,我们需要新增加一个模块目录:
再app下面创建

如:content
下面包含文件:
前台文件的创建:
看下 index.php 的内容:
<?php
// +----------------------------------------------------------------------
// | wuzhicms [ 五指互联网站内容管理系统 ]
// | Copyright (c) 2014-2015 http://www.wuzhicms.com All rights reserved.
// | Licensed ( http://www.wuzhicms.com/licenses/ )
// | Author: wangcanjia
// +----------------------------------------------------------------------
defined('IN_WZ') or exit('No direct script access allowed');
load_function('content','content');
/**
* 网站首页
*/
class index{
private $siteconfigs;
public function __construct() {
$this->siteconfigs = get_cache('siteconfigs');
$this->db = load_class('db');
} /**
* 网站首页
*/
public function index() {
$isindex = 1;
$siteconfigs = $this->siteconfigs;
$seo_title = $siteconfigs['sitename'];
$seo_keywords = $siteconfigs['seo_keywords'];
$seo_description = $siteconfigs['seo_description'];
$categorys = get_cache('category','content');
include T('content','index',TPLID);
} /**
* 内容页面
* url规则 /index.php?v=show&cid=24&id=79
*/
public function show() {
$siteconfigs = $this->siteconfigs;
$id = isset($GLOBALS['id']) ? intval($GLOBALS['id']) : MSG(L('parameter_error'));
$cid = isset($GLOBALS['cid']) ? intval($GLOBALS['cid']) : MSG(L('parameter_error'));
$categorys = get_cache('category','content');
//查询数据
$category = get_cache('category_'.$cid,'content');
$models = get_cache('model_content','model'); $model_r = $models[$category['modelid']];
$master_table = $model_r['master_table'];
$data = $this->db->get_one($master_table,array('id'=>$id));
if(!$data || $data['status']!=9) MSG('信息不存在或者未通过审核!');
if($model_r['attr_table']) {
$attr_table = $model_r['attr_table'];
if($data['modelid']) {
$modelid = $data['modelid'];
$attr_table = $models[$modelid]['attr_table'];
}
$attrdata = $this->db->get_one($attr_table,array('id'=>$id));
$data = array_merge($data,$attrdata);
} require get_cache_path('content_format','model');
$form_format = new form_format($model_r['modelid']);
$data = $form_format->execute($data);
foreach($data as $_key=>$_value) {
$$_key = $_value['data'];
}
if($template) {
$_template = $template;
} elseif($category['show_template']) {
$_template = $category['show_template'];
} elseif($model_r['template']) {
$_template = TPLID.':'.$model_r['template'];
} else {
$_template = TPLID.':show';
}
$styles = explode(':',$_template);
$project_css = isset($styles[0]) ? $styles[0] : 'default';
$_template = isset($styles[1]) ? $styles[1] : 'show';
$elasticid = elasticid($cid);
$seo_title = $title.'_'.$category['name'].'_'.$siteconfigs['sitename'];
$seo_keywords = !empty($keywords) ? implode(',',$keywords) : '';
$seo_description = $remark;
//上一页
$previous_page = $this->db->get_one($master_table,"`cid`= '$cid' AND `id`>'$id' AND `status`=9",'*',0,'id ASC');
//下一页
$next_page = $this->db->get_one($master_table,"`cid` = '$cid' AND `id`<'$id' AND `status`=9",'*',0,'id DESC');
include T('content',$_template,$project_css);
} /**
* 栏目列表
*/
public function listing() {
$cid = isset($GLOBALS['cid']) ? intval($GLOBALS['cid']) : MSG(L('parameter_error'));
//站点信息
$siteconfigs = $this->siteconfigs;
//栏目信息
$categorys = get_cache('category','content');
$category = get_cache('category_'.$cid,'content');
//分页初始化
$page = max(intval($GLOBALS['page']),1);
//分页规则
$urlrule = ''; if($category['child']) {
$_template = $category['category_template'];
} else {
$_template = $category['list_template'];
}
if(empty($_template)) $_template = TPLID.':list';
$styles = explode(':',$_template);
$project_css = isset($styles[0]) ? $styles[0] : 'default';
$_template = isset($styles[1]) ? $styles[1] : 'show';
$seo_title = $category['name'].'_'.$siteconfigs['sitename'];
$seo_keywords = $category['seo_keywords'];
$seo_description = $category['seo_description'];
$elasticid = elasticid($cid);
$model_r = get_cache('model_content','model');
$master_table = $model_r[$category['modelid']]['master_table'];
if($category['type']==1) {
$r = $this->db->get_one($master_table,array('cid'=>$cid));
if($r) {
extract($r,EXTR_SKIP);
if($attr_table = $model_r[$category['modelid']]['attr_table']) {
$r = $this->db->get_one($attr_table,array('id'=>$id));
extract($r,EXTR_SKIP);
}
}
}
include T('content',$_template,$project_css);
}
}
?>
完整的访问路径:
http://www.wuzhicms.com/index.php?m=content&f=index&v=listing&cid=2
通过参数:m=content //模块名
f=index //文件名(控制器)
v=方法名(视图)
这个就是MCV架构。
后台文件的创建:
首先登录后台,添加后台菜单:
路径:维护界面>后台菜单管理>

在扩展模块栏目:添加子菜单。

添加完成后,就会在对应的菜单下面找到。

后台文件的编写:
后台文件一定要放置到 admin目录。
在:模块目录下:coreframe/app/link/admin/下面添加文件。

具体可以参考下:
defined('IN_WZ') or exit('No direct script access allowed');
/**
* 友情链接
*/
load_class('admin');
class index extends WUZHI_admin {
private $db;
function __construct() {
$this->db = load_class('db');
}
/**
* 友情链接列表
*/
public function listing() {
$page = isset($GLOBALS['page']) ? intval($GLOBALS['page']) : 1;
$page = max($page,1);
$result = $this->db->get_list('link', '', '*', 0, 20,$page,'sort ASC');
$pages = $this->db->pages;
$total = $this->db->number;
include $this->template('listing');
}
wuzhicms 模块开发的更多相关文章
- AngularJS多模块开发
angularJS中的多模块开发是指多个module模块开发,步骤为: 1. 确定主模块 var app=angular.module('myApp',[]); 2. 其他的子模块添加到主模块后 ...
- js模块开发(一)
现在嵌入页面里面的javascript代码越来越复杂,于是可能依赖也越来越严重,使用别人开发的js也越来越多,于是在理想情况下,我们只需要实现核心的业务逻辑,其他都可以加载别人已经写好的模块. 于是j ...
- seajs实现JavaScript 的 模块开发及按模块加载
seajs实现了JavaScript 的 模块开发及按模块加载.用来解决繁琐的js命名冲突,文件依赖等问题,其主要目的是令JavaScript开发模块化并可以轻松愉悦进行加载. 官方文档:http:/ ...
- Asp.net Mvc模块化开发之“开启模块开发、调试的简单愉快之旅”
整个世界林林种种,把所有的事情都划分为对立的两个面. 每个人都渴望的财富划分为富有和贫穷,身高被划分为高和矮,身材被划分为胖和瘦,等等. 我们总是感叹,有钱人的生活我不懂;有钱人又何尝能懂我们每天起早 ...
- 基于ASP.NET MVC的热插拔模块式开发框架(OrchardNoCMS)--模块开发
之前文章中给大家说明了下我这个小小的想法,发现还是有不少人的支持和关注.你们的鼓励是对我最大的支持. 我总结了了大家的评论,有以下几个问题: 1.希望有更多的文档说明. 2.希望介绍下Orchard的 ...
- js 模块开发之一(模块开发价值)
首先引用我们的今天的主角 ----<前端模块化开发的价值> 1,前端开发最常见的两个问题 ---命名冲突和文件依赖 2,对于命名冲突的基本解决办法就是学习其他语言的习惯,添加命名空间 va ...
- nginx模块开发篇 (阿里著作)
背景介绍 nginx历史 使用简介 nginx特点介绍 nginx平台初探(100%) 初探nginx架构(100%) nginx基础概念(100%) connection request 基本数据结 ...
- Drupal8开发教程:模块开发——创建新页面
之前我们已经通过<Drupal8开发教程:认识.info.yml文件>对模块的YAML文件有了了解,今天我们来看如何通过模块开发的方式添加一个新的页面. 在 Drupal 7 中,通过模块 ...
- SpringMvc+jquery easyui模块开发7步骤
搞了一段java的开发,总结出模块开发经验: SpringMvc+jquery easyui模块开发7步骤:1) 数据表(table): 定义表结构并创建数据表t_use ...
随机推荐
- mysql 权限管理
参考: http://www.cnblogs.com/Richardzhu/p/3318595.html 一.MySQL权限简介 关于mysql的权限简单的理解就是mysql允许你做你全力以内 ...
- 宏 #,##,_ _VA_ARGS_ _
宏里面使用: 一.# 转为字符串 #define PSQR(x) printf("the square of" #x "is %d.\n",(x)*(x)) ...
- samba配置smb.conf
[share] path = /home/phinecos/share available = yes browsealbe = yes public = ye ...
- linux后台执行命令&
当在前台运行某个作业时,终端被该作业占据:而在后台运行作业时,它不会占据终端.可以使用&命令把作业放到后台执行. 如:30 2 * * * /data/app/scripts/hotbacku ...
- BZOJ 3533 sdoi 2014 向量集
设(x,y)为Q的查询点,分类讨论如下:1.y>0: 最大化a*x+b*y,维护一个上凸壳三分即可 2.y<0:最大化a*x+b*y 维护一个下凸壳三分即可 我们考虑对时间建出一棵线段 ...
- Win7 默认hosts文件
# Copyright (c) 1993-2009 Microsoft Corp. # # This is a sample HOSTS file used by Microsoft TCP/IP f ...
- Android EditText控件行尾为表情时的BUG
今天处理项目上的一个诡异BUG,贴吧Android客户端发贴框是支持表情文字混排的,但是当发贴框的行内容末尾为表情时,尝试在表情后插入文字,就悲剧了:文字其实写进去了,但是不会显示出来.研究了一下,发 ...
- jquery ui autoComplete自动完成
官网:http://jqueryui.com/autocomplete 最简单的形式: var availableTags = [ "ActionScript", "Ap ...
- FTPClient 工具类
package com.photoann.core.util; import java.io.BufferedInputStream; import java.io.File; import java ...
- Android开发之ADT导入Support Library
在工程中增加(例如 support-v4 Library) 在ADT中需要按照以下步骤: 1.右击当前工程,查找Properties 2.选择Java Build Path 3.选择Librarie ...