phpcms常用接口调用方法

时间:2024-01-17 12:06:08

常用函数 , 打开include/global.func.php,下面存放一些公共函数

view plaincopy to clipboardprint?
function str_charset($in_charset, $out_charset, $str_or_arr) //转换字符串或者数组的编码  
function set_cookie($var, $value = '', $time = 0) //设置cookie  
function get_cookie($var) //取得cookie  
function menu($parentid, $code = '') //获取菜单  
function is_ie() //判断当前浏览器是否为IE  
function is_date($ymd, $sep='-') //检查日期的合法性  
function is_email($email) //验证Email  
function file_down($filepath, $filename = '') //下载函数  
function ip() //取得IP地址  
function str_cut($string, $length, $dot = '...') //截取字符串  
function cache_read($file, $path = '', $iscachevar = 0) //读取缓存  
function cache_write($file, $array, $path = '') //写缓存  
function cache_delete($file, $path = '') //删除缓存文件  
function string2array($data) //把字符串转化成数组  
function array2string($data, $isformdata = 1) //把数组转换成字符串  
function subarea($parentid = 0) //取得地区  
function subtype($module = 'phpcms') //取得模块的分类  
function thumb($imgurl, $width = 100, $height = 100 ,$autocut = 1) //生成缩略图  
function get_sql_catid($catid) //取得$catid的所有子栏目ID  
function get_sql_in($string, $s = ' ') //创建一个in 子句  
function pages($total, $page = 1, $perpage = 20, $urlrule = '', $array = array(), $catid = 0) //分页函数  
function showmessage($msg, $url_forward = 'goback', $ms = 1250, $direct = 0) //创建提示信息  
function load($file, $module = 'phpcms', $dir = '', $isinit = 1) //包含一个类文件(如同:include_once),同时返回一个对象  
function areaname($areaid) //返回$areaid 对应的地区名字  
function username($userid) //取得用户名  
function userid($username) //取得用户id
function str_charset($in_charset, $out_charset, $str_or_arr) //转换字符串或者数组的编码
function set_cookie($var, $value = '', $time = 0) //设置cookie
function get_cookie($var) //取得cookie
function menu($parentid, $code = '') //获取菜单
function is_ie() //判断当前浏览器是否为IE
function is_date($ymd, $sep='-') //检查日期的合法性
function is_email($email) //验证Email
function file_down($filepath, $filename = '') //下载函数
function ip() //取得IP地址
function str_cut($string, $length, $dot = '...') //截取字符串
function cache_read($file, $path = '', $iscachevar = 0) //读取缓存
function cache_write($file, $array, $path = '') //写缓存
function cache_delete($file, $path = '') //删除缓存文件
function string2array($data) //把字符串转化成数组
function array2string($data, $isformdata = 1) //把数组转换成字符串
function subarea($parentid = 0) //取得地区
function subtype($module = 'phpcms') //取得模块的分类
function thumb($imgurl, $width = 100, $height = 100 ,$autocut = 1) //生成缩略图
function get_sql_catid($catid) //取得$catid的所有子栏目ID
function get_sql_in($string, $s = ' ') //创建一个in 子句
function pages($total, $page = 1, $perpage = 20, $urlrule = '', $array = array(), $catid = 0) //分页函数
function showmessage($msg, $url_forward = 'goback', $ms = 1250, $direct = 0) //创建提示信息
function load($file, $module = 'phpcms', $dir = '', $isinit = 1) //包含一个类文件(如同:include_once),同时返回一个对象
function areaname($areaid) //返回$areaid 对应的地区名字
function username($userid) //取得用户名
function userid($username) //取得用户id

数据库类,打开include/db_mysql.class.php
系统会自动载入 db_mysql.class.php 文件,并用进行初始化数据库连接,因此在工程所有文件中均不需要单独初始化这个类,可直接用$db 进行操作,为了防止错误,操作完后不必关闭数据库

常用的方法:
1、执行一个非查询类型的SQL语句,如 insert 、create 、update 等
$db->query($sql);
返回值为是否执行成功。
2、对数据库进行插入操作
$db->insert($tablename, $array);//$tablename 表名,$array 字段名与值的对应 数组
返回值为是否执行成功。
3、执行一条更新操作
$db->update($tablename, $array, $where);// $tablename 表名, $array 字段名与值的对应 数组, $where 更新条件
返回值为是否执行成功。
4、返回单条记录
$db->get_one($sql);
5、执行条件查询语句
$result = $db->query($sql);
while($r = $db->fetch_array($result))
{
}
等效于:
$arr = $db->select($sql);
6、重新选择要操作的数据库
$db->select_db($tablename);
7、获取上一个插入的自动递增主键id值
$db->insert_id();
8、获得MySql的版本号
$db->version();
9、析放某查询的资源
$db->free_result($result);

--------------------------------------------------------------------------------------------------------

1、./libs/functions/global.func.php
    
--------------------------------------------------
字符串安全处理函数
-------------------------------------------------------
    new_addslashes($string) 返回经 addslashes处理过得字符或数组
    
    new_stripslashes($string)返回经stripslashes处理过得字符或数组

new_htmlspecialchars($string)返回经htmlspecialchars处理过得字符或数组

safe_replace($string)  安全过滤函数

trim_textarea($string)  格式化文本域: 新行前添加换行标记,空格转为&nbsp

trim_script  转义 javascript 代码标记
    
   str_cut($string/字符串, $length/截取长度, $dot = '...'/结尾填充)  支持UTF8/GBK
-----------------------------------------
   get_url() 获取当前页面完整URL地址

ip()   获取请求IP
------------------------------------------
字符串操作类函数
----------------------------------------------
    random($length, $chars = '0123456789') 产生随机字符串
    
    生成随机字符串create_randomstr($lenth = 6) 范围:'123456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ'

string2array($data)    字符串转为数组
    
    array2string($data, $isformdata = 1)  数组转为字符串

--------------------
字符串加密解密
--------------------
   sys_auth($string, $operation = 'ENCODE'/ENCODE加密,DECODE为解密,默认为ENCODE, $key = ''密钥, $expiry = 0/过期时间)

--------------------------------------------------
语言方法
    L ($language = '数组中的键名',$pars = array(), $modules = '对应模块语言')  //$modules=''时默认为system.lang.php  返回键值
---------------------------------------------
调用前台模板
===============
     template($module = 'content'/对应模块, $template = 'index'/页面, $style = '')

调用后台模板
    
    admin::admin_tpl($file/文件名, $m = ''/默认为文件所在模块)
------------------------------------------------------------------
提示信息页面跳转 showmessage($msg/信息, $url_forward = 'goback'/跳转位置, $ms = 1250, $dialog = '', $returnjs = '')   //有待更改默认后台跳到admin,前台:content
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

fileext($filename) 取得文件扩展名

|||||||||||||||||||||||||||||||||||||||||||||||||||||

缓存操作
--------------
   写入缓存    setcache($name/名称, $data/数据, $filepath=''/路径(默认caches/caches_$filepath/caches_data/), $type='file'(默认)/缓存类型[file,memcache,apc], $config='', $timeout=0/过期时间)

加载模板标签缓存  tpl_cache($name,$times = 0)                                         目的文件:caches/caches_$filepath/caches_data/$name.cache.php

读取缓存  getcache($name, $filepath='', $type='file', $config='')

删除缓存  delcache($name, $filepath='', $type='file', $config='')    
 
  读取缓存文件信息 getcacheinfo($name, $filepath='', $type='file', $config='')
|||||||||||||||||||||||||||||||||||||||||||||||||||||

分页函数  pages($num,      $curr_page, $perpage = 20, $urlrule = '', $array = array(),$setpages = 10)   返回分页

信息总数, 当前分页,  每页显示数,   URL规则...

URL路径解析,pages 函数的辅助函数  url_par($par, $url = '')  $par 默认为page={$page}  返回URL

验证邮箱    is_email($email)

检查用户名是否符合规定  is_username($username)

///////////////////////////////////////////////

网站一些参数获取
==================

获取当前的站点ID  get_siteid()

获取用户昵称       get_nickname($userid='', $field='')  不传入userid取当前用户nickname,如果nickname为空取username||传入field,取用户$field字段信息

通过ID获取用户信息       get_memberinfo($userid, $field='')  不传入$field返回用户所有信息,传入field,取用户$field字段信息

通过 username 值,获取用户所有信息   get_memberinfo_buyusername($username, $field='')

获取用户头像,建议传入phpssouid  get_memberavatar($uid/默认为phpssouid, $is_userid='', $size='30')

///////////////////////////////////////////////
    
    判断IE浏览器  is_ie()

文件下载    file_down($filepath/文件路径, $filename = ''/文件名称)

对用户的密码进行加密  password($password, $encrypt='')

对(字符串或数组)数据进行编码转换    array_iconv($data, $input = 'gbk', $output = 'utf-8')

生成缩略图函数   thumb($imgurl, $width = 100, $height = 100 ,$autocut = 1, $smallpic = 'nopic.gif')

水印添加    watermark($source, $target = '',$siteid)
===========================================================================

生成SEO  seo($siteid, $catid = '', $title = '', $description = '', $keyword = '')   返回数组

站点ID    ,栏目ID,  标题      ,  描述             ,关键词

获取站点的信息   siteinfo($siteid)

生成CNZZ统计代码tjcode()

获取站点域名siteurl($siteid)

文本转换为图片   string2img($txt, $fonttype = 5, $fontsize = 16, $font = '', $fontcolor = 'FF0000',$transparent = '1')

|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-----------------------------------------------   -----------------------------------
2、./libs/functions/iconv.func.php   字符编码转换函数

3、./libs/functions/mail.func.php   发邮件函数

4、./libs/functions/extention.func.php  扩展函数

--------------------------------------------------------------------------------------------------------

1、可视化编辑器的调用方法
需要用到editor函数,editor($textareaid = 'content', $toolbar = 'phpcms', $width = 500, $height = 400)

$textareaid 为文本框 id
$toolbar 为工具按钮样式,目前有 phpcms 和 introduce 两种可以选择,一般较大的内容编辑框用 phpcms,而简要介绍则用 introduce
$width 指定编辑器的宽度
$height 指定编辑器的高度

例如:在文章模块发布文章时的内容编辑采用可视化编辑器的代码如下

<textarea name="article[content]" id="content" cols="60" rows="4"></textarea>
<?=editor("content","phpcms",550,400)?>

2、验证码的调用方法

在模板中调用验证码
<input name="checkcodestr" type="text" size="15">
<img src="{PHPCMS_PATH}checkcode.php" id="checkcode"   style="cursor:pointer;" alt="验证码,看不清楚?请点击刷新验证码" align="absmiddle"/>

验证验证码是否正确的php代码
checkcode($checkcodestr, $PHPCMS['enableadmincheckcode'], $PHP_REFERER);

该函数原型如下:
checkcode($checkcode, $enable = 1, $forward = '')
$checkcode 为用户输入的值,$enable 为当前验证码是否启用,$forward 指定当用户输入的验证码错误后的跳转地址

3、模板调用方法

前台

include template($mod, $file);
$mod 为模板所属的模块,$file 为模板去后缀 .html 后的文件名

后台

include admintpl($file);
$file 为模板去后缀 .tpl.php 后的文件名

4、生成html的方法

首先把创建html的php程序存放到模块目录的 include/createhtml/ 目录下,然后通过 createhtml($filename, $mod_root="") 函数来调用并生成html
$filename 为 include/createhtml/ 目录下去了 .inc.php 后的文件名,$mod_root 为当前模块目录的物理路径,可省略

例如以下代码可以生成文章ID号为1的文章html页:
$articleid = 1;
createhtml('show') ;

关于生成html的详细方法参见文章模块代码(./module/article/)

5、给标题进行颜色和是否加粗的控制调用方法

首先应该在标题所在的数据表中创建一个 style 字段来存放样式值,然后在模板中标题的输入框旁边插入以下代码:
添加信息时:<?=style_edit($inputname, '')?>
编辑信息时:<?=style_edit($inputname, $style)?>

系统将根据 $inputname 变量的值创建一个隐藏表单,和标题一样,该表单值会随着表单的提交而发送给php,应该把该值存放到 style 字段。

在显示标题时,需要使用以下代码:
$title = style($title, $style);

6、后台子菜单调用方法

类似以下代码
$submenu = array
(
array("管理首页", "?mod=".$mod."&file=".$file."&channelid=".$channelid."&action=manage"),
array("添加栏目", "?mod=".$mod."&file=".$file."&channelid=".$channelid."&action=add"),
array("合并栏目", "?mod=".$mod."&file=".$file."&channelid=".$channelid."&action=join"),
array("栏目数据修复", "?mod=".$mod."&file=".$file."&channelid=".$channelid."&action=repair")
);
$menu = adminmenu("栏目管理",$submenu);

7、操作提示信息调用方法

showmessage($msg, $url_forward = '');

$msg 为提示信息,$url_forward 为跳转地址

8、用户组选择框的调用方法

showgroup($type = 'select', $name = 'groupid', $checked = '', $perline = 5)

$type 可选值为 select 、 checkbox 、radio ,分别可以产生下拉菜单、复选框、单选按钮
$name 为要创建的表单名
$checked 为选定的值
$perline 当显示类型为单选或者复选时用来控制每行的显示个数

此方法在按用户组设置权限时需要用到

9、模板选择下拉框调用方法

showtpl($module = 'phpcms', $type = 'index', $name = 'templateid', $templateid = 0, $property = '')

$module 为要调用的模板所属的模块
$type 为模板类型名,比如首页模板类型为 index
$name 为下拉框表单名
$templateid 被选定的模板名
$property 表单附加属性,比如js或者id可以在这里写

10、风格选择下拉框调用方法

showskin($name = 'skinid', $skinid = '', $property = '')

$name 为下拉框表单名
$skinid 为选定的风格名
$property 表单附加属性,比如js或者id可以在这里写

11、频道选择下拉框调用方法

channel_select($module = '', $name = 'channelid', $defaultalt = '', $channelid = 0, $property = '')

$module 指定频道所属模块,如果不指定则生成所有频道的下拉选择
$name 下拉表单名
$defaultalt 默认选中的提示信息,比如可写“请选择频道”
$channelid 选中的频道id
$property 表单附加属性,比如js或者id可以在这里写

12、栏目选择下拉框调用方法

category_select($name = 'catid', $defaultalt = '', $catid = 0, $property = '')

$name 为下拉表单名
$defaultalt 默认选中的提示信息,比如可写“请选择栏目”
$catid 选中的栏目id
$property 表单附加属性,比如js或者id可以在这里写

在调用此函数前应该先加载 ./include/tree.class.php 并实例化 tree 类创建好一个 $tree 对象
此函数默认产生当前频道的栏目下拉框

13、专题选择下拉框调用方法

special_select($channelid = 0, $name = 'specialid', $defaultalt = '请选择专题', $specialid = 0, $property = '')

$channelid 指定专题所属的频道
$name 为下拉表单名
$defaultalt 默认选中的提示信息,比如可写“请选择专题”
$specialid 选中的专题id
$property 表单附加属性,比如js或者id可以在这里写

14、专题子分类选择下拉框调用方法

special_type_select($specialid, $name = 'special_typeid', $defaultalt = '请选择子类', $typeid = 0, $property = '')

$specialid 指定专题id
$name 为下拉表单名
$defaultalt 默认选中的提示信息,比如可写“请选择子分类”
$typeid 选中的子分类id
$property 表单附加属性,比如js或者id可以在这里写

15、附属分类调用方法

type_select($typeids, $name = 'typeid', $defaultalt = '类别', $typeid = 0, $property = '')

$typeids 当前频道或者模块所选用的所有子分类id,可以是数组,也可以是逗号分割开的数字字串
$name 为下拉表单名
$defaultalt 默认选中的提示信息,比如可写“请选择分类”
$typeid 选中的分类id
$property 表单附加属性,比如js或者id可以在这里写

16、url规则选择下拉框调用方法

urlrule_select($name, $fileext = 'html', $type = 'cat', $urlruleid = 0, $property = '')

$name 为下拉表单名
$fileext 可选值为 html 和 php
$type 可选值为 cat、item、special
$urlruleid 选中的url规则id
$property 表单附加属性,比如js或者id可以在这里写

17、单网页选择下拉框调用方法

page_select($channelid = 0, $property = '')

$channelid   指定单网页所属频道id
$property 表单附加属性,比如js或者id可以在这里写

18、模块配置保存方法

每个模块都应该有自己的配置信息,可以自己根据需要来建立配置表单,保存的时候统一根据
module_setting($module, $setting)
来进行配置保存

$module 为配置所属的模块
$setting 为模块配置所组成的数组

参见:./admin/setting.inc.php

19、在可复制模块中调用栏目管理的方法

添加栏目:?mod=phpcms&file=category&action=add&channelid=1
管理栏目:?mod=phpcms&file=category&action=manage&channelid=1
合并栏目:?mod=phpcms&file=category&action=join&channelid=1

其中 channelid 参数应该为当前频道 ID

20、在可复制模块中调用专题管理的方法

添加专题:?mod=phpcms&file=special&action=add&channelid=1
管理专题:?mod=phpcms&file=special&action=manage&channelid=1
合并专题:?mod=phpcms&file=special&action=join&channelid=1

其中 channelid 参数应该为当前频道 ID

21、在可复制模块中调用附属分类管理的方法

url: ?mod=phpcms&file=type&action=setting&channelid=1

其中 channelid 参数应该为当前频道 ID

22、在独立模块中调用栏目管理的方法

请自行参考 ./product/admin/category.inc.php

23、在独立模块中调用附属分类管理的方法

url: ?mod=phpcms&file=type&action=setting&module=product

其中 module 参数应该为当前模块名

24、自定义字段功能的调用方法

phpcms自定义字段功能是通过给数据表增加前缀为 my_ 的字段来实现的,适用于所有带信息发布的模块和频道,下面讲一下调用方法:
在频道或者模块的导航中做一个链接,例如文章模块调用url为:

?mod=phpcms&file=field&action=manage&channelid=1&tablename=phpcms_article_1

注意:tablename 为要定义字段的数据表名,这个参数不能少

那么在发表文章的程序中显示自定义字段表单应该这样得到:

require PHPCMS_ROOT.'/admin/include/field.class.php';
$field = new field('phpcms_article_1');

$fieldform = $field->get_form('tablerow'); // tablerow 为css样式名

文章发表时自定义自段的内容应该这样保存:

$field->update('articleid=1'); // articleid=1 这个表示更新 articleid 为 1 的文章的自定义自段内容

前台显示自定义自段内容的方法和显示标题 title 类似

25、得到栏目下级栏目信息得调用方法

subcat($keyid, $catid = 0, $type = 'menu');

$keyid 可以是 频道id , 也可以是模块英文名
$catid 为栏目ID
$type 可选值为 menu 或 list,分别表示导航和列表

26、得到当前位置得方法

前台:catpos($catid, $s = '>>');
后台:admin_catpos($catid, $s = '>>');

27、发送邮件的方法

require PHPCMS_ROOT.'/include/mail.inc.php';
1、可视化编辑器的调用方法
需要用到editor函数,editor($textareaid = 'content', $toolbar = 'phpcms', $width = 500, $height = 400)

$textareaid 为文本框 id
$toolbar 为工具按钮样式,目前有 phpcms 和 introduce 两种可以选择,一般较大的内容编辑框用 phpcms,而简要介绍则用 introduce
$width 指定编辑器的宽度
$height 指定编辑器的高度

例如:在文章模块发布文章时的内容编辑采用可视化编辑器的代码如下

<textarea name="article[content]" id="content" cols="60" rows="4"></textarea>
<?=editor("content","phpcms",550,400)?>

2、验证码的调用方法

在模板中调用验证码
<input name="checkcodestr" type="text" size="15">
<img src="{PHPCMS_PATH}checkcode.php" id="checkcode"   style="cursor:pointer;" alt="验证码,看不清楚?请点击刷新验证码" align="absmiddle"/>

验证验证码是否正确的php代码
checkcode($checkcodestr, $PHPCMS['enableadmincheckcode'], $PHP_REFERER);

该函数原型如下:
checkcode($checkcode, $enable = 1, $forward = '')
$checkcode 为用户输入的值,$enable 为当前验证码是否启用,$forward 指定当用户输入的验证码错误后的跳转地址

3、模板调用方法

前台

include template($mod, $file);
$mod 为模板所属的模块,$file 为模板去后缀 .html 后的文件名

后台

include admintpl($file);
$file 为模板去后缀 .tpl.php 后的文件名

4、生成html的方法

首先把创建html的php程序存放到模块目录的 include/createhtml/ 目录下,然后通过 createhtml($filename, $mod_root="") 函数来调用并生成html
$filename 为 include/createhtml/ 目录下去了 .inc.php 后的文件名,$mod_root 为当前模块目录的物理路径,可省略

例如以下代码可以生成文章ID号为1的文章html页:
$articleid = 1;
createhtml('show') ;

关于生成html的详细方法参见文章模块代码(./module/article/)

5、给标题进行颜色和是否加粗的控制调用方法

首先应该在标题所在的数据表中创建一个 style 字段来存放样式值,然后在模板中标题的输入框旁边插入以下代码:
添加信息时:<?=style_edit($inputname, '')?>
编辑信息时:<?=style_edit($inputname, $style)?>

系统将根据 $inputname 变量的值创建一个隐藏表单,和标题一样,该表单值会随着表单的提交而发送给php,应该把该值存放到 style 字段。

在显示标题时,需要使用以下代码:
$title = style($title, $style);

6、后台子菜单调用方法

类似以下代码
$submenu = array
(
array("管理首页", "?mod=".$mod."&file=".$file."&channelid=".$channelid."&action=manage"),
array("添加栏目", "?mod=".$mod."&file=".$file."&channelid=".$channelid."&action=add"),
array("合并栏目", "?mod=".$mod."&file=".$file."&channelid=".$channelid."&action=join"),
array("栏目数据修复", "?mod=".$mod."&file=".$file."&channelid=".$channelid."&action=repair")
);
$menu = adminmenu("栏目管理",$submenu);

7、操作提示信息调用方法

showmessage($msg, $url_forward = '');

$msg 为提示信息,$url_forward 为跳转地址

8、用户组选择框的调用方法

showgroup($type = 'select', $name = 'groupid', $checked = '', $perline = 5)

$type 可选值为 select 、 checkbox 、radio ,分别可以产生下拉菜单、复选框、单选按钮
$name 为要创建的表单名
$checked 为选定的值
$perline 当显示类型为单选或者复选时用来控制每行的显示个数

此方法在按用户组设置权限时需要用到

9、模板选择下拉框调用方法

showtpl($module = 'phpcms', $type = 'index', $name = 'templateid', $templateid = 0, $property = '')

$module 为要调用的模板所属的模块
$type 为模板类型名,比如首页模板类型为 index
$name 为下拉框表单名
$templateid 被选定的模板名
$property 表单附加属性,比如js或者id可以在这里写

10、风格选择下拉框调用方法

showskin($name = 'skinid', $skinid = '', $property = '')

$name 为下拉框表单名
$skinid 为选定的风格名
$property 表单附加属性,比如js或者id可以在这里写

11、频道选择下拉框调用方法

channel_select($module = '', $name = 'channelid', $defaultalt = '', $channelid = 0, $property = '')

$module 指定频道所属模块,如果不指定则生成所有频道的下拉选择
$name 下拉表单名
$defaultalt 默认选中的提示信息,比如可写“请选择频道”
$channelid 选中的频道id
$property 表单附加属性,比如js或者id可以在这里写

12、栏目选择下拉框调用方法

category_select($name = 'catid', $defaultalt = '', $catid = 0, $property = '')

$name 为下拉表单名
$defaultalt 默认选中的提示信息,比如可写“请选择栏目”
$catid 选中的栏目id
$property 表单附加属性,比如js或者id可以在这里写

在调用此函数前应该先加载 ./include/tree.class.php 并实例化 tree 类创建好一个 $tree 对象
此函数默认产生当前频道的栏目下拉框

13、专题选择下拉框调用方法

special_select($channelid = 0, $name = 'specialid', $defaultalt = '请选择专题', $specialid = 0, $property = '')

$channelid 指定专题所属的频道
$name 为下拉表单名
$defaultalt 默认选中的提示信息,比如可写“请选择专题”
$specialid 选中的专题id
$property 表单附加属性,比如js或者id可以在这里写

14、专题子分类选择下拉框调用方法

special_type_select($specialid, $name = 'special_typeid', $defaultalt = '请选择子类', $typeid = 0, $property = '')

$specialid 指定专题id
$name 为下拉表单名
$defaultalt 默认选中的提示信息,比如可写“请选择子分类”
$typeid 选中的子分类id
$property 表单附加属性,比如js或者id可以在这里写

15、附属分类调用方法

type_select($typeids, $name = 'typeid', $defaultalt = '类别', $typeid = 0, $property = '')

$typeids 当前频道或者模块所选用的所有子分类id,可以是数组,也可以是逗号分割开的数字字串
$name 为下拉表单名
$defaultalt 默认选中的提示信息,比如可写“请选择分类”
$typeid 选中的分类id
$property 表单附加属性,比如js或者id可以在这里写

16、url规则选择下拉框调用方法

urlrule_select($name, $fileext = 'html', $type = 'cat', $urlruleid = 0, $property = '')

$name 为下拉表单名
$fileext 可选值为 html 和 php
$type 可选值为 cat、item、special
$urlruleid 选中的url规则id
$property 表单附加属性,比如js或者id可以在这里写

17、单网页选择下拉框调用方法

page_select($channelid = 0, $property = '')

$channelid   指定单网页所属频道id
$property 表单附加属性,比如js或者id可以在这里写

18、模块配置保存方法

每个模块都应该有自己的配置信息,可以自己根据需要来建立配置表单,保存的时候统一根据
module_setting($module, $setting)
来进行配置保存

$module 为配置所属的模块
$setting 为模块配置所组成的数组

参见:./admin/setting.inc.php

19、在可复制模块中调用栏目管理的方法

添加栏目:?mod=phpcms&file=category&action=add&channelid=1
管理栏目:?mod=phpcms&file=category&action=manage&channelid=1
合并栏目:?mod=phpcms&file=category&action=join&channelid=1

其中 channelid 参数应该为当前频道 ID

20、在可复制模块中调用专题管理的方法

添加专题:?mod=phpcms&file=special&action=add&channelid=1
管理专题:?mod=phpcms&file=special&action=manage&channelid=1
合并专题:?mod=phpcms&file=special&action=join&channelid=1

其中 channelid 参数应该为当前频道 ID

21、在可复制模块中调用附属分类管理的方法

url: ?mod=phpcms&file=type&action=setting&channelid=1

其中 channelid 参数应该为当前频道 ID

22、在独立模块中调用栏目管理的方法

请自行参考 ./product/admin/category.inc.php

23、在独立模块中调用附属分类管理的方法

url: ?mod=phpcms&file=type&action=setting&module=product

其中 module 参数应该为当前模块名

24、自定义字段功能的调用方法

phpcms自定义字段功能是通过给数据表增加前缀为 my_ 的字段来实现的,适用于所有带信息发布的模块和频道,下面讲一下调用方法:
在频道或者模块的导航中做一个链接,例如文章模块调用url为:

?mod=phpcms&file=field&action=manage&channelid=1&tablename=phpcms_article_1

注意:tablename 为要定义字段的数据表名,这个参数不能少

那么在发表文章的程序中显示自定义字段表单应该这样得到:

require PHPCMS_ROOT.'/admin/include/field.class.php';
$field = new field('phpcms_article_1');

$fieldform = $field->get_form('tablerow'); // tablerow 为css样式名

文章发表时自定义自段的内容应该这样保存:

$field->update('articleid=1'); // articleid=1 这个表示更新 articleid 为 1 的文章的自定义自段内容

前台显示自定义自段内容的方法和显示标题 title 类似

25、得到栏目下级栏目信息得调用方法

subcat($keyid, $catid = 0, $type = 'menu');

$keyid 可以是 频道id , 也可以是模块英文名
$catid 为栏目ID
$type 可选值为 menu 或 list,分别表示导航和列表

26、得到当前位置得方法

前台:catpos($catid, $s = '>>');
后台:admin_catpos($catid, $s = '>>');

27、发送邮件的方法

require PHPCMS_ROOT.'/include/mail.inc.php';

if(sendmail("[email=zhongshenghui@163.com,phpcms@163.com]zhongshenghui@163.com,phpcms@163.com[/email]", "邮件主题", "邮件内容", "测试<>"))
echo "发送成功";
else echo "失败";

函数原型:sendmail($mail_to, $mail_subject, $mail_body, $mail_from = '')

$mail_to:可以是 user@example.com user@example.com, anotheruser@example.com User <user@example.com> User <user@example.com>, Another User $mail_from:可以是 或 User

28、日期选择的调用方法

date_select($name, $value = '', $format = 'yyyy-mm-dd')
$name 是表单名
$value 是表单的默认值,例如:2006-12-16
$format 日期格式,一般这个参数不用指定
if(sendmail("[email=zhongshenghui@163.com,phpcms@163.com]zhongshenghui@163.com,phpcms@163.com[/email]", "邮件主题", "邮件内容", "测试<>"))
echo "发送成功";
else echo "失败";

函数原型:sendmail($mail_to, $mail_subject, $mail_body, $mail_from = '')

$mail_to:可以是 user@example.com user@example.com, anotheruser@example.com User <user@example.com> User <user@example.com>, Another User $mail_from:可以是 或 User

28、日期选择的调用方法

date_select($name, $value = '', $format = 'yyyy-mm-dd')
$name 是表单名
$value 是表单的默认值,例如:2006-12-16
$format 日期格式,一般这个参数不用指定