phpcms记录

发表于:2023-11-26 11:01技术,php,phpcms热度:22喜欢:0

页面对于代码位置

渲染控制器

phpcms/modules/content/index.php

全局方法定义

phpcms/libs/functions/global.func.php

pc content 标签位置

phpcms/modules/content/classes/content_tag.class.php

pc special标签位置

phpcms/modules/special/classes/special_tag.class.php

二次开发的一些功能

专题添加字段

  1. 找到phpcms/modules/special/templates/special_add.tpl.phpphpcms/modules/special/templates/special_add.tpl.php
    <table class="table_form" width="100%" cellspacing="0">
    内部添加字段,如
    <tr>
      <th width="200">SEO标题</th>
      <td><input name="special[seo_title]" id="seo_title" class="input-text" value="<?php echo new_html_special_chars($info['seo_title']); ?>" type="text" size="40">
      </td>
     </tr>
  2. 在phpcms的数据库中 v9_special表中添加字段 seo_title

专题页面增加搜索和筛选功能

  1. /phpcms/modules/special/templates/special_list.tpl.php 的myform1 前方增加一个表单
    <form name="myform2" action="index.php" method="get">
     	<input type="hidden" name="m" value="special">
     	<input type="hidden" name="c" value="special">
     	<input type="hidden" name="a" value="init">
     	<input type="hidden" name="menuid" value="<?php echo $_GET['menuid'] ?>">
     	<input type="hidden" name="page" value="<?php echo $_GET['page'] ? intval($_GET['page']) : 0 ?>">
     	<div class="explain-col">
     		所属分类:<select name="classtype" value="<?php echo $_GET['classtype'] ?>">
     			<option  value="">全部</option>
     			<option <?php if($_GET['classtype']=='软件合集') echo 'selected' ?> value="软件合集">软件合集</option>
     			<option <?php if($_GET['classtype']=='游戏合集') echo 'selected' ?> value="游戏合集">游戏合集</option>
     			<option <?php if($_GET['classtype']=='游戏专题') echo 'selected' ?> value="游戏专题">游戏专题</option>
     			<option <?php if($_GET['classtype']=='软件专题') echo 'selected' ?> value="软件专题">软件专题</option>
     		</select>
     		关键词:<input name="title" type="text" value="<?php echo $_GET['title'] ?>" class="input-text">
     		<input type="submit" name="search" class="button" value="搜索">
     	</div>
     </form>
  2. /phpcms/modules/special/special.php改写init方法
    public function init() {
     	$page = max(intval($_GET['page']), 1);
     	$_condition = array('siteid'=>$this->get_siteid());
     	
     	$classtype = $_GET['classtype'];
     	$title = $_GET['title'];
    
     	if (!empty($classtype) && $classtype !== '') {
     		$_condition['classtype'] = $classtype;
     	}
    
     	if (!empty($title) && $title !== '') {
     		$_condition['title'] = $title;
     	}
    
    
     	$infos = $this->db->listinfo($_condition, '`listorder` DESC, `id` DESC', $page, 6);
     	pc_base::load_sys_class('format', '', 0);
     	include $this->admin_tpl('special_list');
     }
     

SEO 标签位置

批量编辑栏目的时候,批量更新分类url规则,

// 批量更新栏目
function findIndex(name) {
  let i = 0;
  $('#table-lists tr').each((index, ele) => {
    const text = $(ele).find('b').eq(0).text() || '';
    if (text.startsWith(name)) {
      i = index;
    }
  });;
  return i
}

// 栏目页生成url
$('#table-lists tr').eq(findIndex('栏目生成Htm')).find('[boxid="ishtml"][value=0]').each((index, e) => {
  $(e).click()
})

// 内容页生成url
$('#table-lists tr').eq(findIndex('内容页生成Html')).find('[boxid="content_ishtml"][value=0]').each((index, e) => {
  $(e).click()
})

// 栏目规则设置id
$('#table-lists tr').eq(findIndex('栏目页URL规则')).find('[name^=category_php_ruleid]').each((index, e) => {
  $(e).val("30");
})

// 内容页规则
$('#table-lists tr').eq(findIndex('内容页URL规则')).find('[name^=show_php_ruleid]').each((index, e) => {
  $(e).val("32");
})


``