if (!function_exists('diy_get_arcurl'))
{
/**
* 获取前台文档的URL
* @param integer $aid 文档ID
* @param integer $typeid 栏目ID
* @return [type] [description]
*/
function diy_get_arcurl($aid = 0, $typeid = 0){
$url = '';
if (!empty($aid)) {
static $arctypeList = null;
if (null === $arctypeList) {
$arctypeList = M('arctype')->order('id asc')->getAllWithIndex('id');
}
$row = !empty($arctypeList[$typeid]) ? $arctypeList[$typeid] : [];
if (!empty($row)) {
$row['aid'] = $aid;
$url = arcurl('home/View/index', $row);
}
}
return $url;
}
}
//根据应用标题获取对应产品列表
if(!function_exists('diy_get_pro')){
function diy_get_pro($title = ''){
$title = trim($title);
$title = htmlspecialchars_decode($title);
$where_data = "b.cp_yy like '%".$title."%'";
$data = M('archives')
->field("a.typeid,a.aid,a.title,a.litpic,a.seo_description")
->alias('a')
->join('__ARTICLE_CONTENT__ b', 'a.aid = b.aid', 'LEFT')
->where($where_data)
->select();
$list=array();
foreach($data as $key=>$v){
$aid = $v['aid'];
$typeid = $v['typeid'];
$list[$key]['arcurl'] = diy_get_arcurl($aid,$typeid);
$list[$key]['title'] = $v['title'];
$list[$key]['litpic'] = $v['litpic'];
$list[$key]['seo_description'] = $v['seo_description'];
}
return $list;
}
}
//根据栏目id获取相应的第一个子栏目
if(!function_exists('diy_get_one_child')){
function diy_get_one_child($typeid){
$typeid = intval(trim($typeid));
$type_where=[
'parent_id' => $typeid,
'status' => 1
];
$type_data = M('arctype')->where($type_where)->order('sort_order asc,id asc,add_time asc')->find();
if($type_data){
$xin_typeid = $type_data['id'];
$xin_where=[
'typeid' => $xin_typeid,
'status' => 1
];
$xin_data = M('archives')->where($xin_where)->order('aid asc')->find();
$xin_aid = $xin_data['aid'];
$xin_arcurl = diy_get_arcurl($xin_aid,$xin_typeid);
return $xin_arcurl;
}else{
echo '无子栏目及其文章';
}
}
}
//根据栏目id获取第一篇文章的链接
if(!function_exists('diy_get_one_data')){
function diy_get_one_data($typeid){
$typeid = intval(trim($typeid));
if($typeid){
$xin_typeid = $typeid;
$xin_where=[
'typeid' => $xin_typeid,
'status' => 1
];
$xin_data = M('archives')->where($xin_where)->order('aid asc')->find();
$xin_aid = $xin_data['aid'];
$xin_arcurl = diy_get_arcurl($xin_aid,$xin_typeid);
return $xin_arcurl;
}else{
echo '无子栏目及其文章';
}
}
}