PHPCMS

原文路径:http://bbs.phpcms.cn/thread-711220-1-1.html

第三节,模型设置和栏目设置
在这里一定要注意次序 
先增模型那怕是不完善的模型,一定要先设置,然后建立对应的模板,那怕是一个空模板文件。原因很简单回头修改设置好了的栏目属性会是一件非常疼苦的事,在这点DEDE更人性化,更简单。
设置完了模型后,就可以设置栏目了,栏目可以批量建立,也可以一个一个的建立。
处理完这些,为了SEO进行个性化的栏目访问地址,这时会出现栏目不能正常访问了,这是phpcms的一个小BUG。
通过网上找的解决方式修改程序后可以正常使用
也就是当超过三级采用相对路径时phpcms v9的文件夹存储路径就发生了错误
解决:查找admin模型下category.php  (phpcmsmodulesadmincategory.php)

查找函数 function get_parentdir($catid)
修改

//--------------------------------
        /**
         * 获取父栏目路径
         * @param  $catid
         */
      function get_parentdir($catid) {
                if($this->categorys[$catid]['parentid']==0) return '';
                $r = $this->categorys[$catid];
                $setting = string2array($r['setting']);
                $url = $r['url'];
                $arrparentid = $r['arrparentid'];
                $pid = $r['parentid'];
                unset($r);
                if (strpos($url, '://')===false) {
                        if ($setting['creat_to_html_root']) {
                                return '';
                        } else {
                                $arrparentid = explode(',', $arrparentid);
                                $arrcatdir = array();
                                foreach($arrparentid as $id) {
                                        if($id==0) continue;
                                        $rr = $this->categorys[$id];
                                        $rsetting = string2array($rr['setting']);
                                        if($rsetting['create_to_html_root'] && $id==$pid)
                                        {
                                                return  $this->categorys[$id]['catdir']."/";
                                        }
                                        else $arrcatdir[] = $this->categorys[$id]['catdir'];
                                }
                                return implode('/', $arrcatdir).'/';
                        }
                } else {
                        if ($setting['create_to_html_root']) {
                                if (preg_match('/^((http|https)://)?([^/]+)/i', $url, $matches)) {
                                        $url = $matches[0].'/';
                                        $rs = $this->db->get_one(array('url'=>$url), '`parentdir`,`catid`');
                                        if ($catid == $rs['catid']) return '';
                                        else return $rs['parentdir'];
                                } else {
                                        return '';
                                }
                        } else {
                                $arrparentid = explode(',', $arrparentid);
                                $arrcatdir = array();
                                krsort($arrparentid);
                                foreach ($arrparentid as $id) {
                                        if ($id==0) continue;
                                        $arrcatdir[] = $this->categorys[$id]['catdir'];
                                        if ($this->categorys[$id]['parentdir'] == '') break;
                                }
                                krsort($arrcatdir);
                                return implode('/', $arrcatdir).'/';
                        }
                }
        }
原文地址:https://www.cnblogs.com/hanshuai0921/p/7208338.html