[关闭]
@JRuiCoder 2015-11-25T12:22:49.000000Z 字数 4928 阅读 2222

动易模板与HopeCMS模板转换

HopeCMS


1、栏目建立

栏目提示、栏目描述有的话就要添加
栏目标识符要特别注意命名规范
内容模型的勾选
一些栏目添加的小技巧

2、标签和模板的应用

标签的添加,命名 添加一个分类和分类
模板添加一个文件夹,里面可分为首页、栏目页、内容页、单页模板或者功能页模板

3、风格文件的添加

路径需要修改

4、栏目ID对应关系

5、管理员账号的分配

6、具体的使用方法

a.头部文件引入

  1. <!DOCTYPE html>
  2. <html lang="ch">
  3. <head>
  4. ${My_DeChem_HeadFile}
  5. <title>${HopeTag.PageTitle}</title>
  6. ${HopeTag.MetaKeywords}
  7. ${HopeTag.MetaDescription}
  8. </head>
  9. <body>

b.路径替换

{PE.SiteConfig.ApplicationPath/}改为${HopeTag.InstallDir}

c.动易标签引用

{PE.Label id="spmelab_header"/}
HopeCMS的标签引入方式是${标签名} 例如 ${My_DeChem_Header}

d.通用信息列表

  1. {PE.Label id="通用信息列表" bindStyle="表格式common" titleLength="100" outputQty="5" nodes="2551" displayDateTime="yyyy-mm-dd" displayTips="true" /}

HopeCMS采用

  1. <ul class="list">
  2. #set($List = ${HopeTag.ArticleListSource(44,true,6)})
  3. #if($List.Count > 0)
  4. #set($aIndex = 1)
  5. #foreach($a in $List)
  6. <li class="list_item">
  7. <span class="list_time">${HopeTag.FormatDateTime($a.UpdateTime)}</span>
  8. <div class="list_item_contentBox">
  9. <a href="${HopeTag.GetItemLink($a.GeneralID)}">${HopeTag.FormatString("$a.Title",50)}</a>
  10. </div>
  11. </li>
  12. #set($aIndex= $aIndex + 1)
  13. #end
  14. #else
  15. <li><a>暂无文章!</a></li>
  16. #end
  17. </ul>

e.栏目链接和文章链接

栏目链接:
有三种方式:
通过栏目ID进行获取:${HopeTag.GetCategoryLink(ID)}
相对路径:${HopeTag.InstallDir}+相对路径 例如 ${HopeTag.InstallDir}SchoolIntro/Index.aspx
绝对路径
文章链接
${HopeTag.GetItemLink($Art.GeneralID)}

f. 页码的实现

  1. #set($List = ${HopeTag.ArticlePageSource($CID,false,15)})
  2. <!--S page-->
  3. <div class="hope_pager_web internal_page_web">${HopeTag.InputPager(5)}</div>
  4. <div class="hope_pager_mobile internal_page_mobile">${HopeTag.InputPager(5)}</div>
  5. <!--E page-->

g.美元符号$的使用

jQuery中使用$表示jQuery,但是HopeCMS标签的调用也有用$符号,容易造成冲突

h. 上一篇下一篇的实现

动易:

  1. <div id="preNext">
  2. <ul >
  3. <li>{PE.Label id="上一篇" displayDateTime="true" linkOpenType="2" itemId="@RequestInt_Id" nodeArray="{PE.Field id="cone" fieldname="NodeID" /}" /}
  4. </li>
  5. <li>{PE.Label id="下一篇" displayDateTime="true" linkOpenType="2" itemId="@RequestInt_Id" nodeArray="{PE.Field id="cone" fieldname="NodeID" /}" /}
  6. </li>
  7. </ul>
  8. </div>

HopeCMS:

  1. <div id="preNext">
  2. <ul>
  3. ${HopeTag.PrevNextArticle}
  4. </ul>
  5. </div>

i. 内容页的实现

动易的内容页在开头模板都有这么一段代码
{PE.DataSource id="cone" datasource="文章_内容页" itemId="@RequestInt_id" xslt="true" /}
装换的时候不用管,直接删了,这是获取文章来源的。HopeCMS不用这种方式。以下是HopeCMS常用内容页模板比较常用的东西,把它直接放再这里了。
注释版

  1. #set($Art = ${HopeTag.Article}) <!--获取文章来源,并赋值给变量$Art-->
  2. <h1 class="article_title common_article_title">$Art.Title</h1><!--获取文章标题-->
  3. #if(${HopeTag.GetValue("SubTitle")} != "") <!--判断副标题不为空-->
  4. #if(${HopeTag.GetValue("SubTitle")} != "Null") <!--判断副标题不为Null-->
  5. <h2 class="article_title common_article_title" style="font-size:14px">${HopeTag.GetValue("SubTitle")}</h2> <!--获取文章副标题-->
  6. #end
  7. #end
  8. <div class="article_info">
  9. 作者:
  10. #if(${HopeTag.GetValue("Author")} != "")<!--判断作者不为空-->
  11. ${HopeTag.GetValue("Author")}
  12. #else
  13. ${HopeTag.GetValue("Inputer")} <!--作者为空的话使用录入者的用户名-->
  14. #end&nbsp;&nbsp;来源:
  15. #if(${HopeTag.GetValue("CopyFrom")} != "")<!--判断来源不为空-->
  16. #if(${HopeTag.GetValue("CopyFrom")} !="Null")<!--判断来源不为Null-->
  17. ${HopeTag.GetValue("CopyFrom")} <!--获取文章来源-->
  18. #end
  19. #end
  20. &nbsp;&nbsp;发布时间:
  21. ${HopeTag.FormatDateTime($Art.InputTime)}<!--获取文章录入时间-->
  22. &nbsp;&nbsp;点击数:${HopeTag.Article.Hits} <!--获取文章点击数-->
  23. </div>
  24. <div class="article_body">
  25. ${HopeTag.GetValue("Content")} <!--获取文章内容-->
  26. </div>
  27. <div class="article_editor">
  28. 文章录入:$Art.Inputer <!--获取文章录入者--> &nbsp;&nbsp;&nbsp;&nbsp; 责任编辑:$Art.Editor<!--获取文章责任编辑-->
  29. </div>

无注释版

  1. #set($Art = ${HopeTag.Article})
  2. <h1 class="article_title common_article_title">$Art.Title</h1>
  3. #if(${HopeTag.GetValue("SubTitle")} != "")
  4. #if(${HopeTag.GetValue("SubTitle")} != "Null")
  5. <h2 class="article_title common_article_title" style="font-size:14px">${HopeTag.GetValue("SubTitle")}</h2>
  6. #end
  7. #end
  8. <div class="article_info">
  9. 作者:
  10. #if(${HopeTag.GetValue("Author")} != "")
  11. ${HopeTag.GetValue("Author")}
  12. #else
  13. ${HopeTag.GetValue("Inputer")}
  14. #end&nbsp;&nbsp;来源:
  15. #if(${HopeTag.GetValue("CopyFrom")} != "")
  16. #if(${HopeTag.GetValue("CopyFrom")} !="Null")
  17. ${HopeTag.GetValue("CopyFrom")}
  18. #end
  19. #end
  20. &nbsp;&nbsp;发布时间:
  21. ${HopeTag.FormatDateTime($Art.InputTime)}
  22. &nbsp;&nbsp;点击数:${HopeTag.Article.Hits}
  23. </div>
  24. <div class="article_body">
  25. ${HopeTag.GetValue("Content")}
  26. </div>
  27. <div class="article_editor">
  28. 文章录入:$Art.Inputer &nbsp;&nbsp;&nbsp;&nbsp; 责任编辑:$Art.Editor
  29. </div>

对于有内容模型的,会有一些相应的字段,这时我们通用的获取的方式就是${HopeTag.GetValue("字段名")},比如我的内容模型里面有一个参考文献的字段名叫ref。则获取的方式就是${HopeTag.GetValue("ref")}

j. 位置导航

  1. #set($depth = ${HopeTag.CategoryDepth})
  2. #set($RID = ${HopeTag.RootCategoryID})
  3. #set($CID = ${HopeTag.CurrentCategoryID})
  4. #set($RName = ${HopeTag.GetCategoryName($RID)})
  5. #set($CName = ${HopeTag.GetCategoryName($CID)})
  6. <div class="main_location">
  7. <div class="main_location_locationInfo">
  8. <span class="main_location_location-icon"></span>
  9. 您所在的位置:
  10. <a href="${HopeTag.SiteUrl}" title="${HopeTag.SiteName}">${HopeTag.SiteName}</a>#if($depth == 3) &#62;&#62; <a href="${HopeTag.GetCategoryLink($RID)}" title="$RName">$RName</a>#end &#62;&#62; <a href="${HopeTag.GetCategoryLink($CID)}" title="$CName">$CName</a>
  11. </div>
  12. </div>

常用的HopeCMS标签

文章栏目链接
${HopeTag.GetItemLink($Art.GeneralID)}
文章的标题
${HopeTag.FormatString("$Art.Title",20)}
获取当前栏目名
${HopeTag.CurrentCategoryName}
获取当前栏目ID
${HopeTag.CurrentCategoryID}
获取默认栏目首页图片或者文章封面图片
${HopeTag.GetSourceDefaultPicUrl($Art)}

常见的一些错误

1、没有链接时使用双#号,即##,这会被注释掉,后面的内容会消失

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注