PHP教程

phpcms v9 根据日期调用全站文章url

本文主要是介绍phpcms v9 根据日期调用全站文章url,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
  • 新增模版
  • 新建一个list2.html(里面内容如下代码)放到模版里
  • {pc:content action="lists" catid="$catid" ccc="1" date="$_GET['date']" order="id DESC" num="100000"} 
    {loop $data $v}
    {$v['url']}<br>
    {/loop}
    {/pc}
  • 新增栏目
  • 内容-管理栏目-添加栏目-随便新增一个文章栏目-栏目列表页模板list2.html
  • 新增代码
  • 代码路径 /phpcms/modules/content/classes/content_tag.class.php  替换lists方法
  • public function lists($data) {
    		$catid = intval($data['catid']);
    		if(!$this->set_modelid($catid)) return false;
    		if(isset($data['where'])) {
    			$sql = $data['where'];
    		} else {
    			$thumb = intval($data['thumb']) ? " AND thumb != ''" : '';
    			if($this->category[$catid]['child']) {
    				$catids_str = $this->category[$catid]['arrchildid'];
    				$pos = strpos($catids_str,',')+1;
    				$catids_str = substr($catids_str, $pos);
    				$sql = "status=99 AND catid IN ($catids_str)".$thumb;
    			} else {
    			    if($data['ccc']==1){
    			    $sj = $data['date'];
    			    $s = strtotime($sj.'00:00:00');
                    $l = strtotime($sj.'23:59:59');
    				$sql = "status=99 AND inputtime>=$s AND inputtime<=$l".$thumb;
    			    }else{
    			    $sql = "status=99 AND catid='$catid'".$thumb; 
    			    }
    			}
    		}
    		$order = $data['order'];
    
    		$return = $this->db->select($sql, '*', $data['limit'], $order, '', 'id');
    						
    		//调用副表的数据
    		if (isset($data['moreinfo']) && intval($data['moreinfo']) == 1) {
    			$ids = array();
    			foreach ($return as $v) {
    				if (isset($v['id']) && !empty($v['id'])) {
    					$ids[] = $v['id'];
    				} else {
    					continue;
    				}
    			}
    			if (!empty($ids)) {
    				$this->db->table_name = $this->db->table_name.'_data';
    				$ids = implode('\',\'', $ids);
    				$r = $this->db->select("`id` IN ('$ids')", '*', '', '', '', 'id');
    				if (!empty($r)) {
    					foreach ($r as $k=>$v) {
    						if (isset($return[$k])) $return[$k] = array_merge($v, $return[$k]);
    					}
    				}
    			}
    		}
    		return $return;
    	}

    网址调用方法:

  • http://www.123.com/index.php?m=content&c=index&a=lists&catid=61&date=2021-11-21

这篇关于phpcms v9 根据日期调用全站文章url的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!