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 ...
随机推荐
- VS2012编译出来的程序,在XP上运行,出现“.exe 不是有效的 win32 应用程序” “not a valid win32 application”
升级vs2010到vs2012,突然发现build出来的应用程序无法运行,提示“不是有效的 win32 应用程序” or “not a valid win32 application”. 参考CSDN ...
- 【技术贴】webservice cxf2 客户端动态调用报错No operation was found with the name
No operation was found with the name xxx 出错原因是因为发布服务的接口所在包路径和此接口实现类包路径不一致,比如你的服务接口可能放在了包com.x.interF ...
- OD之窗口界面
- SQL Server 2008 设计与实现笔记(一)
Chart5 create database MovieRental; select name, SUSER_SNAME(sid) as [login] from sys.database_princ ...
- C#一个简单下载程序实例(可用于更新)
运行时的界面 using System; using System.Collections.Generic; using System.ComponentModel; using System.Dat ...
- [itint5]三数和为0
http://www.itint5.com/oj/#20 其实是3sum的变种,有重复数字,但是一开始还是写错了.其实是选定一个后,在右边剩余数组里找2sum,找到一组后继续找. #include & ...
- C语言 结构体的内存对齐问题与位域
http://blog.csdn.net/xing_hao/article/details/6678048 一.内存对齐 许多计算机系统对基本类型数据在内存中存放的位置有限制,它们会要求这些数据的首地 ...
- 188. Best Time to Buy and Sell Stock IV
题目: 链接: 题解: 测试: Reference:
- autocapticalize和autocorrect
首字母自动大写autocapitalize 在 iOS 中,用户可以手动开启「首字母自动大写」功能,这样输入英文的时候,首字母便会自动大写.但是,有些时候并不希望一直是首字母大写的.比如用户名这个字段 ...
- python中的commands模块
commands模块用于调用shell命令 有3中方法: commands.getstatus() 返回执行状态 commands.getoutput() 返回执行结果 commands.ge ...