JTBC(CMS)

开源与免费的跨平台网站内容管理系统解决方案

腾讯交流群: 2254994
技术支持群: 27032719
首页 » 在线论坛 » ASP版本 
帖子内容
1 楼
hitely
注册会员
积分 22
注册 2010-07-08
     
自定义文章模块的“keywords,title,description”标签内容
在文章模块中,每个网页Head部分的“keywords,title,description”是一成不变的。如果我们要在发布每一篇文章的时候就顺便自定义每篇文章的“keywords,title,description三个元素的内容该咋办了?

在JT的指导下,通过自己改程序实现了目标,下面就请各位跟着我来看看是怎么操作的吧!

以“article”模块做实例:

第一步:添加字段

    1、打开网站根目录下的common\database文件夹,打开“#db.asa”数据库文件,找到“article”数据表,在数据表中添加三个字段,分别是“a_keywords,a_title,a_description”,字段的数据类型是“文本”。
      注:a_”是前缀,不同模块的前缀不同,文章模块里是“d_”。

第二步:在language里增加相对应的文字显示

    1、打开网站根目录下common\language文件夹,打开lng_config.jtbc,往里面增加如下内容:

[p]    <item>
      <disinfo><![CDATA[keywords]]></disinfo>
      <chinese><![CDATA[网页关键字]]></chinese>
    </item>[/p] [p]    <item>
      <disinfo><![CDATA[title]]></disinfo>
      <chinese><![CDATA[网页标题]]></chinese>
    </item>[/p] [p]    <item>
      <disinfo><![CDATA[description]]></disinfo>
      <chinese><![CDATA[网页描述]]></chinese>
    </item>[/p]
第三步:修改后台处理函数

      1、打开"article\common\incfiles"目录,用记事本打开manage_config.asp文件。

      2、找到Sub jtbc_cms_admin_manage_adddisp()这个函数,在rs.Update前增加如下内容:

              rs(cfname("keywords")) = left_intercept(get_str(request.Form("keywords")),150)
              rs(cfname("title")) = left_intercept(get_str(request.Form("title")), 150)
              rs(cfname("description")) = left_intercept(get_str(request.Form("description")),150)

      3、找到Sub jtbc_cms_admin_manage_editdisp()函数,在rs.Update前增加如下内容:

              rs(cfname("keywords")) = left_intercept(get_str(request.Form("keywords")),150)
              rs(cfname("title")) = left_intercept(get_str(request.Form("title")), 150)
              rs(cfname("description")) = left_intercept(get_str(request.Form("description")),150)

第四步:后台添加和修改

        1、打开“article\common\template”文件夹,打开“manage.jtbc”文件。
       
[p]        2、找到<name><![CDATA[add]]></name>节点,在合适的地方添加如下内容:[/p]  
                <tr>
                        <td width="80" height="25">{$=itake('global.lng_config.title','lng')}</td>
                        <td width="*"><input type="text" name="title" size="60"></td>
              </tr>
              <tr>
                        <td width="80" height="25">{$=itake('global.lng_config.keywords','lng')}</td>
                        <td width="*"><input type="text" name="keywords" size="60"></td>
                </tr>
                <tr>
                        <td width="80" height="25">{$=itake('global.lng_config.description','lng')}</td>
                        <td width="*"><textarea rows="5" name="description" cols="60"></textarea></td>
                </tr>
[p]
        3、找到<name><![CDATA[edit]]></name>节点,在合适的地方添加如下内容:[/p]
              <tr>
                      <td width="80" height="25">{$=itake('global.lng_config.title','lng')}</td>
                      <td width="*"><input type="text" name="title" size="60" value="{$title}"></td>
            </tr>
            <tr>
                      <td width="80" height="25">{$=itake('global.lng_config.keywords','lng')}</td>
                      <td width="*"><input type="text" name="keywords" size="60" value="{$keywords}"></td>
            </tr>
            <tr>
                      <td width="80" height="25">{$=itake('global.lng_config.description','lng')}</td>
                      <td width="*"><textarea rows="5" name="description" cols="60">{$description}</textarea></td>
              </tr>

第五步、自定义输出标签(关键所在)

        1、打开“article\common\incfiles”文件夹,打开“module_config.asp”文件。
         
        2、找到“Function jtbc_cms_module_detail()”函数,在该函数中“tmpstr = creplace(tmpstr)
”语句后添加如下内容:
                tmpstr = Replace(tmpstr, "{$title}", htmlencode(get_str(rs(cfname("title")))))
                tmpstr = Replace(tmpstr, "{$keywords}", htmlencode(get_str(rs(cfname("keywords")))))
                tmpstr = Replace(tmpstr, "{$description}", htmlencode(get_str(rs(cfname("description")))))”

第六步、添加自定义头部模板

          1、打开网站根目录下的“common\template”文件夹,打开“tpl_public.jtbc”文件。

          2、 添加如下自定义头部模板节点内容:
[p]<name><![CDATA[self_define_head]]></name>
  <tpl_default><![CDATA[[/p] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
{$=web_base()}
<meta http-equiv="x-ua-compatible" content="IE=EmulateIE7" />
<meta name="robots" content="all" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="zh-cn" />
<meta name="keywords" content="{$keywords}" />
<meta name="description" content="{$description}" />
<title>{$title}</title>

<script type="text/javascript" src="{$global.images}js/main.js"></script>
<script type="text/javascript" src="{$global.images}js/writeflashhtml2.js"></script>
<link type="text/css" rel="stylesheet" href="{$global.images}theme/{$=nskin}/layout.css" />
</head>
]]></tpl_default>
</item>

第七步、修改前台详情页面所调用的头部模板

          1、打开"article\common\template"文件夹,打开“module.jtbc”文件。

[p]          2、找到“<name><![CDATA[detail]]></name>”节点,修改节点内容中的“{$=web_head(nhead)}”为“{$=web_head('self_define_head')}”。(也就是把默认的头部模板名修改为你刚才添加的那个头部模板名)[/p]
经过以上的七个步骤,在添加文章的时候,就可以自定义“keywords,title,description”的内容了。当然其他模块需要此功能也可以这样添加。

实例网站:http://www.nnhuibo.com/hbnews

如果还有什么问题,可以加我Q:5757663,一起交流学习。
本帖由 hitely 于 2010-09-01 13:24:49 编辑过
2010-08-18 16:10:36
2 楼
jetiben
管理员
积分 7082
注册 2006-06-28
     
回复:
黄金广告位出租~
2010-08-18 22:19:05
3 楼
new
银牌会员
积分 806
注册 2009-06-30
     
回复: 自定义文章模块的“keywords,title,description”标签内容
黄金广告位求租~
2010-08-19 16:27:15
4 楼
blueyrs
注册会员
积分 16
注册 2010-05-25
     
回复: 自定义文章模块的“keywords,title,description”标签内容
谢谢,前段时间就为这个发帖子,没找到答案,其他做好了,没做第五步,怎么也调不出来,终于有没搞出来了
2010-08-19 17:34:18