力荐:文章标题颜色设置

2016-07-07 15:18 来源:www.chinab4c.com 作者:ecshop专家

1.ALTER TABLE `ecs_article` ADD `article_title_color` VARCHAR( 20 ) NULL AFTER `title` ;
首先把这个sql运行一下
2.把以下代码放到 admin/js/articletitle-colorselector.js这里 (呵呵,没看到上传附件的地方,贴代码了)
var ColorSelecter = new Object();

ColorSelecter.Show = function(sender)
{
if(ColorSelecter.box)
{
if (ColorSelecter.box.style.display = "none")
ColorSelecter.box.style.display = "";
}
else
{
ColorSelecter.box = document.createElement("Div");
ColorSelecter.box.id = "ColorSelectertBox";
var table = "<table width='93' border='1' cellpadding='0' cellspacing='0' bordercolor='#BDBBBC' style='border:2px #C5D9FE solid'><tr><td bgcolor='#FFFFFF'>&nbsp;</td><td bgcolor='#C0C0C0'>&nbsp;</td><td bgcolor='#969696'>&nbsp;</td><td bgcolor='#808080'>&nbsp;</td><td bgcolor='#333333'>&nbsp;</td></tr><tr><td bgcolor='#CC99FE'>&nbsp;</td><td bgcolor='#993365'>&nbsp;</td><td bgcolor='#81007F'>&nbsp;</td><td bgcolor='#6766CC'>&nbsp;</td><td bgcolor='#343399'>&nbsp;</td></tr><tr><td bgcolor='#BBBBBB'>&nbsp;</td><td bgcolor='#00CCFF'>&nbsp;</td><td bgcolor='#3366FF'>&nbsp;</td><td bgcolor='#0000FE'>&nbsp;</td><td bgcolor='#010080'>&nbsp;</td></tr><tr><td bgcolor='#CDFFFF'>&nbsp;</td><td bgcolor='#01FFFF'>&nbsp;</td><td bgcolor='#33CBCC'>&nbsp;</td><td bgcolor='#008081'>&nbsp;</td><td bgcolor='#003265'>&nbsp;</td></tr><tr><td bgcolor='#CDFFCC'>&nbsp;</td><td bgcolor='#00FF01'>&nbsp;</td><td bgcolor='#339967'>&nbsp;</td><td bgcolor='#008002'>&nbsp;</td><td bgcolor='#013300'>&nbsp;</td></tr><tr><td bgcolor='#FFFE99'>&nbsp;</td><td bgcolor='#FFFE03'>&nbsp;</td><td bgcolor='#99CD00'>&nbsp;</td><td bgcolor='#807F01'>&nbsp;</td><td bgcolor='#333301'>&nbsp;</td></tr><tr><td bgcolor='#FFCB99'>&nbsp;</td><td bgcolor='#FFCD00'>&nbsp;</td><td bgcolor='#FF9900'>&nbsp;</td><td bgcolor='#FD6600'>&nbsp;</td><td bgcolor='#993400'>&nbsp;</td></tr><tr><td bgcolor='#FF99CB'>&nbsp;</td><td bgcolor='#FF00FE'>&nbsp;</td><td bgcolor='#FE0000'>&nbsp;</td><td bgcolor='#800000'>&nbsp;</td><td bgcolor='#000000'>&nbsp;</td></tr></table>";
ColorSelecter.box.innerHTML = table;
document.body.appendChild(ColorSelecter.box);
var myTable = ColorSelecter.box.childNodes[0];
for (var i = 0; i<myTable.rows.length; i++)
{
for (var j = 0; j < myTable.rows.cells.length; j++)
{
myTable.rows.cells[j].style.border = "#BDBBBC 1px solid";
myTable.rows.cells[j].onmousemove = function()
{
this.style.border = "#fff 1px solid";
}
myTable.rows.cells[j].onmouseout = function()
{
this.style.border = "#BDBBBC 1px solid";
}
myTable.rows.cells[j].onmousedown = function()
{
document.getElementById("font_color").style.backgroundColor = this.bgColor;
document.getElementById("article_title_color").value = this.bgColor;
document.getElementsByName("goods_name").item(0).style.color = this.bgColor;
ColorSelecter.box.style.display = "none";
}
}
}
}
var pos = getPosition(sender);
ColorSelecter.box.style.top= pos.top + 18 + "px";
ColorSelecter.box.style.left = pos.left + "px";

document.onmousedown = function()
{
ColorSelecter.box.style.display = "none";
}

}
3.打开admin/templates/article_info.htm
第3行替换成 {insert_scripts files="../js/utils.js,selectzone.js,articletitle-colorselector.js,validator.js"}
然后在大约23行处<td class="narrow-label">{$lang.title}</td>
后面添加

<td>
<input type="text" name="title" size ="40"style="float:left;color:{$article.article_title_color};"maxlength="60" value="{$article.title|escape}" />{$lang.require_field}
<div style="background-color:{$article.article_title_color};float:left;margin-left:2px;" id="font_color" onclick="ColorSelecter.Show(this);"><img src="images/color_selecter.gif" style="margin-top:-1px;" /></div><input type="hidden" id="article_title_color" name="article_title_color" value="{$article_title_color}" />&nbsp;

</td>
4.打开article。dwt 大约65行处修改<font class="f5 f6" style="color:{$article.article_title_color}">{$article.title|escape:html}</font><br /><font class="f3">{$article.author|escape:html} / {$article.add_time}</font>
找不到?在打开的文档搜索上面红色部分
5.还想要什么?成功了哦,去看看先,呵呵,觉得有用的要顶哦

回答:
不能用啊,文章里面不能显示颜色,提交后的字段里面颜色字段是空的。 没有出现错误提示