官方首页 | 无图版 | BBS首页
PJBlog3 2.8.5.157 新版发布 下载|升级(2008.8.26) 来给PJ3提提发展建议 2008版 PJHOME 珍藏/纪念版官方T恤 正式发布! PJ3内测团队主创人员身份,性格,特点吐血大曝光
PJBlog技术支持论坛使用问题总索引 PJ-Blog 3 斑竹日志 【独家】我使用过的三种空间,与客服的精彩故事 Z-Blog,Wordpress,Bo-Blog转换到PJBlog
发新话题
打印

为你的blog添加2级分类

本主题由 thomas 于 2007-2-7 16:39 解除高亮

为你的blog添加2级分类

哈哈
吼吼

                                             上面表格纯属娱乐,如有雷同,绝对巧合..
------------------------------
为你的blog实现2级分类
--------------------------------
方法简单,高手毋笑..

====================
很多blog都有2级分类的功能
用了PJ以来发现没有这个有点小小的不爽
但是PJ的后台模块功能叫我想到一个方法实现
在侧边自己添加代码
====================
步骤:
1:进后台自定义一个侧边模块
2:把代码放进去.
3.保存


Ps:我只是测试了下,还能用,出错直接删除模块就好
    RSS自己在后面添加就行了...

下面就直接把我的代码公布下
代码可以随便修改
版权不是我的<我也不知道是谁的>
====================
懒的复制代码的直接下载附件吧
我打个包..

    <script language="javascript">
  • //item object//alert("arrived here");
  • function PhenItem(id,pid,label,url,type,img,over,img2,over2,title,target){
  • this.id=id;this.pid=pid;
  • this.label=label;this.url=url;
  • this.title=title;this.target=target;
  • this.img=img;this.over=over;
  • this.img2=img2;this.over2=over2;
  • this.type=type;//this._ih = false; //is it the head item?
  • this._hc = false; //has the child item?this._ls = false; //has sibling item?
  • this._io = false; //whether the panelbar is open?};
  • //menu objectfunction PhenMenu(objName) {
  • this.config = {
  •   closeSameLevel : true
  • };
  • //alert("asdsdf"); this.obj = objName;
  • this.items = [];
  • this.root = new PhenItem(-1);
  •   };
  • //add a new item to the item array
  • PhenMenu.prototype.add = function(id,pid,label,url,type,img,over,img2,over2,title,target){ this.items[this.items.length] = new PhenItem(id,pid,label,url,type,img,over,img2,over2,title,target);
  • };
  • // Outputs the menu to the pagePhenMenu.prototype.toString = function() {
  • //alert("arrived here"); var str = '<div>\n';
  • if (document.getElementById) {
  •   str += this.addItem(this.root);
  • } else str += 'Browser not supported.';
  • str += '\n</div>';
  • //alert(str); //document.write(str);
  • //alert(this.items[0]._hc); return str;
  • };
  • // Creates the menu structure
  • PhenMenu.prototype.addItem = function(pItem) {
  • var str = '';
  • //var n=0;
  • for (var n=0; n<this.items.length; n++) {   
  •   if(this.items[n].pid == pItem.id){   
  •    var ci = this.items[n];   //alert(ci.pid);
  •    //alert(ci.id);   this.setHS(ci);
  •    //alert("item:"+ci._hc);   //alert(ci._ls);
  •    str += this.itemCreate(ci, n);   
  •    if(ci._ls) break;   
  •   }
  • }
  • return str;
  • };
  • // Creates the node icon, url and textPhenMenu.prototype.itemCreate = function(pItem, itemId) {
  • //alert(pItem.type.toLowerCase()); var str = '';
  • if(pItem.type == 'header')
  • str = '<table width="100%" class="header" valign="middle"   COLOR: #0000ff">+this.obj+'.o('+itemId+')"><tr><td>';
  • else  str = '<table width="100%" class="item" valign="middle"   COLOR: #0000ff">+this.obj+'.o('+itemId+')"><tr><td>';
  • if (pItem.img) {
  •   str += ' <img id="i' + this.obj + itemId + '" src="' + pItem.img + '" alt="" />';
  • }
  • if (pItem.url) {  str += '<a id="s' + this.obj + itemId + '" class="navigation_item" href="' + pItem.url + '"';
  •   if (pItem.title) str += ' title="' + pItem.title + '"';  if (pItem.target) str += ' target="' + pItem.target + '"';
  •   str += ' COLOR: #0000ff">+ pItem.label + '\';return true;" ';  str += '>';
  • } str += ' ' + pItem.label;
  • if (pItem.url) str += '</a>'; str += '</td></tr></table>';
  • //alert(pItem.url); //alert(str);
  • if (pItem._hc) {  str += '<table id="ct' + this.obj + itemId + '" width="100%" style="display:' + ((pItem._io) ? 'block' : 'none') + '; FILTER: blendTrans(Duration=3.0); VISIBILITY: hidden"><tr><td>';
  •   str += this.addItem(pItem);  str += '</td></tr></table>';
  •   //alert(str);  //document.write(str);
  • }
  • return str;};
  • // Checks whether a item has child and if it is the last siblingPhenMenu.prototype.setHS = function(pItem) {
  • var lastId;
  • for (var n=0; n<this.items.length; n++) {
  •   if (this.items[n].pid == pItem.id) pItem._hc = true;
  •   if (this.items[n].pid == pItem.pid) lastId = this.items[n].id;
  • }
  • if (lastId==pItem.id) pItem._ls = true;
  • };
  • // Toggle Open or close
  • PhenMenu.prototype.o = function(id) { //alert(this.items.length);
  • var ci = this.items[id];//alert(ci);
  • //this.setHS(ci); //alert(this.items[id]._hc);
  • this.itemStatus(!ci._io, id);
  • ci._io = !ci._io;
  • if (this.config.closeSameLevel) this.closeLevel(ci);
  • };
  • // Change the status of a item(open or closed)PhenMenu.prototype.itemStatus = function(status, id) {
  • cTable = document.getElementById('ct' + this.obj + id);
  • if(status){
  •      cTable.filters.item(0).Apply();
  •   cTable.style.display = 'block';  cTable.style.visibility = "";
  •   cTable.filters.item(0).Play(); }
  • else  cTable.style.display = 'none';
  • //cDiv.style.display = (status) ? 'block': 'none';
  • };
  • // Closes all items on the same level as certain item
  • PhenMenu.prototype.closeLevel = function(pItem) {//alert(this.items[0]._hc);
  • for (var n=0; n<this.items.length; n++) {//alert(this.items[n]._hc);
  •   if ((this.items[n].pid == pItem.pid) && (this.items[n].id != pItem.id) && this.items[n]._hc) {   
  •    this.itemStatus(false, n);
  •    this.items[n]._io = false;
  •    this.closeAllChildren(this.items[n]);
  •   }
  • }
  • };
  • PhenMenu.prototype.closeAllChildren = function(pItem) {
  • for (var n=0; n<this.items.length; n++) {
  •   if (this.items[n].pid == pItem.id && this.items[n]._hc) {
  •    if (this.items[n]._io) this.itemStatus(false, n);
  •    this.items[n]._io = false;
  •    this.closeAllChildren(this.items[n]);  
  •   }
  • }
  • };</script>
  • <style>.header {
  • height:25px; FONT-FAMILY: Arial,Verdana;
  • background-image:url(images/sideNavCategoryBg.gif); font-size:11px;
  • color: #666666;
  • }.headerSelected {  
  • height:25px; FONT-FAMILY: Arial,Verdana;
  • background-image:url(images/sideNavCategorySelectedBg.gif); font-size:11px;
  • background-repeat:repeat-x; COLOR: #333333;
  • CURSOR: pointer;}
  • .navigation_item {
  • PADDING-LEFT: 20px; FONT-SIZE: 11px; CURSOR: pointer; COLOR: #000000; FONT-FAMILY: Arial,Verdana; HEIGHT: 20px; TEXT-DECORATION: none}
  • .item {PADDING-LEFT: 2px; FONT-SIZE: 11px; CURSOR: pointer; COLOR: #000000; FONT-FAMILY: Arial,Verdana; HEIGHT: 20px;
  • }.itemOver {
  • PADDING-LEFT: 2px; FONT-SIZE: 11px; CURSOR: pointer; COLOR: #333333; FONT-FAMILY: Arial,Verdana; HEIGHT: 20px; font-weight:bold; background-color:#EDEDED}
  • .itemSelected { PADDING-LEFT: 20px; FONT-SIZE: 11px; CURSOR: pointer; COLOR: #000000; FONT-FAMILY: Arial,Verdana; HEIGHT: 20px; TEXT-DECORATION: underline;
  • }
  • A.headerSelected { PADDING-RIGHT: 0px; PADDING-LEFT: 0px; BACKGROUND-IMAGE: none; PADDING-BOTTOM: 0px; PADDING-TOP: 0px; HEIGHT: 10px
  • }</style>
  • </head><body>
  • <table width="120" border="0" cellspacing="0" cellpadding="0"><tr>
  • <td>
  • <script type="text/javascript">
  •   p = new PhenMenu('p');//alert("asds");
  •   p.add(0,-1,'学习路上','','header','http://dev7.cn/blog/images/icons/1.gif');  p.add(1,0,'ASp','http://dev7.cn/blog/default.asp?cateID=5');
  •   p.add(2,0,'Php','http://dev7.cn/blog/default.asp?cateID=5');  p.add(3,0,'Css','http://dev7.cn/blog/default.asp?cateID=5');
  •   p.add(4,0,'Ajxa','http://dev7.cn/blog/default.asp?cateID=5');   
  •   p.add(5,-1,'label2','','header','http://dev7.cn/blog/images/icons/1.gif');  p.add(6,5,'label2.1','http://dev7.cn/blog/default.asp?cateID=5');
  •   p.add(7,5,'label2.2','http://dev7.cn/blog/default.asp?cateID=5');  p.add(8,5,'label2.3','http://dev7.cn/blog/default.asp?cateID=5');
  •   p.add(9,5,'label2.4','http://dev7.cn/blog/default.asp?cateID=5');   
  •   p.add(10,-1,'label3','','header','http://dev7.cn/blog/images/icons/1.gif');  p.add(11,10,'label3.1','http://dev7.cn/blog/default.asp?cateID=5');
  •   p.add(12,10,'label3.2','http://dev7.cn/blog/default.asp?cateID=5');  p.add(13,10,'label3.3','http://dev7.cn/blog/default.asp?cateID=5');
  •   p.add(14,10,'label3.4','http://dev7.cn/blog/default.asp?cateID=5');   
  •   p.add(15,-1,'label4','','header','http://dev7.cn/blog/images/icons/1.gif');  p.add(16,15,'label4.1','http://dev7.cn/blog/default.asp?cateID=5');
  •   p.add(17,15,'label4.2','http://dev7.cn/blog/default.asp?cateID=5');  p.add(18,15,'label4.3','http://dev7.cn/blog/default.asp?cateID=5');
  •   p.add(19,15,'label4.4','http://dev7.cn/blog/default.asp?cateID=5');//alert(p.items.length)
  •   document.write(p);   
  •   //p.toString();//alert(p.items.length);
  •   //delete(p); </script> </td>
  • </tr></table>
  • </div>
附件: 您所在的用户组无法下载或查看附件

TOP

发着玩.

TOP

哦,真正的二级呢,导航栏的话?

TOP

引用:
原帖由 星铃丹 于 2007-1-3 11 发表
真正的二级就用元旦版吧
改的地方太多了
舍不得放弃原来的
再说我就是觉得分类了还是占那么长的位置怪不好的
本人想分的类比较多 ..
所以这种的可以占小点侧边位置..

TOP

同意楼上的
之前的改的太多了,舍不得放弃
http://zzwzz.cn蜘蛛网

蜘蛛网

TOP

TOP

发新话题