ecshop后台修改添加文章可以自定义时间的实现方法

飘逸的风11年前 (2016-01-04)程序19676

ecshop实现后台文章信息可以修改添加时间的方法。有时我们希望将过去发布的新闻改成今天发布的,或者是今天发布的文章,希望改成是过去发布的,一流资源网今天就分享这个方法。

ecshop实现后台文章信息可以修改添加时间的方法


第一步:

打开 admin/templates/article_info.htm

在第三行下面加入调用日历 JS


<script type="text/javascript" src="../js/calendar.php?lang={$cfg_lang}"></script>
<link href="../js/calendar/calendar.css" rel="stylesheet" type="text/css" />


查找:


<tr>
    <td class="narrow-label">{$lang.author}</td>
    <td><input type="text" name="author" maxlength="60" value="{$article.author|escape}" /></td>
</tr>


在下面新增一行添加以下代码:

<!--新加日期修改-->
<tr>
    <td class="narrow-label">{$lang.add_time}</td>
    <td><input name="add_time" type="text" id="add_time" size="20" value='{$article.add_time}' readonly="readonly" /><input name="selbtn1" type="button" id="selbtn1" onclick="return showCalendar('add_time', '%Y-%m-%d %H:%M', '24', false, 'selbtn1');" value="{$lang.btn_sel ect}" class="button"/></td>
</tr>
<!--新加日期修改 结束-->

第二步:

打开 /admin/article.php 文件

查找:

/*初始化*/
$article = array();
$article['is_open'] = 1;


在下面新增一行添加以下代码:

$article['add_time'] = local_date('Y-m-d H:i');


继续查找:


/* 取文章数据 */
$sql = "SELECT * FROM " .$ecs->table('article'). " WHERE article_id='$_REQUEST[id]'";
$article = $db->GetRow($sql);

在下面新增一行加入以下代码:

$article['add_time'] = local_date('Y-m-d H:i',$article['add_time']);

继续查找:

/*插入数据*/
    $add_time = gmtime();
    if (empty($_POST['cat_id']))
    {
        $_POST['cat_id'] = 0;
    }
    $sql = "INSERT INTO ".$ecs->table('article')."(title, cat_id, article_type, is_open, author, ".
                "author_email, keywords, content, add_time, file_url, open_type, link, description) ".
            "VALUES ('$_POST[title]', '$_POST[article_cat]', '$_POST[article_type]', '$_POST[is_open]', ".
                "'$_POST[author]', '$_POST[author_email]', '$_POST[keywords]', '$_POST[FCKeditor1]', ".
                "'$add_time', '$file_url', '$open_type', '$_POST[link_url]', '$_POST[description]')";
    $db->query($sql);

修改为:

/*插入数据*/
    $add_time = gmtime();
    if (empty($_POST['cat_id']))
    {
        $_POST['cat_id'] = 0;
    }
     $add_time = local_strtotime($_POST['add_time']);
    $sql = "INSERT INTO ".$ecs->table('article')."(title, cat_id, article_type, is_open, author, ".
                "author_email, keywords, content, add_time, file_url, open_type, link) ".
            "VALUES ('$_POST[title]', '$_POST[article_cat]', '$_POST[article_type]', '$_POST[is_open]', ".
                "'$_POST[author]', '$_POST[author_email]', '$_POST[keywords]', '$_POST[FCKeditor1]', ".
                "'$add_time', '$file_url', '$open_type', '$_POST[link_url]')";
    $db->query($sql);

继续查找:

if ($exc->edit("title='$_POST[title]', cat_id='$_POST[article_cat]', article_type='$_POST[article_type]', is_open='$_POST[is_open]', author='$_POST[author]', author_email='$_POST[author_email]', keywords ='$_POST[keywords]', file_url ='$file_url', open_type='$open_type', content='$_POST[FCKeditor1]', link='$_POST[link_url]', description = '$_POST[description]'", $_POST['id']))

修改为:

$add_time = local_strtotime($_POST['add_time']);
if ($exc->edit("title='$_POST[title]', cat_id='$_POST[article_cat]', article_type='$_POST[article_type]', is_open='$_POST[is_open]', author='$_POST[author]', add_time='$add_time',author_email='$_POST[author_email]', keywords ='$_POST[keywords]', file_url ='$file_url', open_type='$open_type', content='$_POST[FCKeditor1]', link='$_POST[link_url]' ", $_POST['id']))
搞定!


原文转载:https://www.16css.com/ecshop/1146.html

相关文章

分享一个生成sitemap.xml的类

很多站长在做seo优化的时候都会向各大搜索引擎网站提交站点地图sitemap.xml,同样需要提交。于是专门写了一个生成sitemap.xml的类,支持生成在制定目录下,默认生成在网站根目录下。 分...

Javascript 正则表达式使用手册

一.正则表达式匹配常用语法 “+”字符:规定表达式字符出现一次或多次。 “*”字符:规定表达式字符出现零次或多次。 “?”字符:规定表达式字符出现零次或一次。 ^ 匹配的是字符的开头 ,匹配的...

38条PHP编码优化加速技巧[转]

1. 尽量采用大量的PHP内置函数。 2. echo 比 print 快。 3. 不要把方法细分得过多,仔细想想你真正打算重用的是哪些代码? 4. 在执行for循环之前确...

php日历的高效写法

标题写的吸引人了些,不过我就觉得是挺高效的,我相信 之前看到过 irlvirus 写的 《php练习代码-日历》,我觉得效率都不是很好。 date()函数结合mktime() 可以得到一切东西...

ECShop仿淘宝商品详细页 实现尺码颜色关联显示库存

ECShop仿淘宝商品详细页 实现尺码颜色关联显示库存

  ecshop服装商城很多都十分需要一个颜色尺码的功能,其实在淘宝,凡客上都类似的功能,客户在下单时选容易选择相应的颜色尺码,其实ecshop要实现这样的功能并不难,因为ecshop是开源免费的。...

PHP给图片添加水印和生成缩略图函数

给图片添加水印: /************************************ 函数: watermark($bigimg, $smallimg, $coord = 1) 作用:...

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。