轻源码

  • QingYuanMa.com
  • 全球最大的互联网技术和资源下载平台
搜索
一起源码网 门户 ECShop网店 查看主题

ECSHOP文章信息可以修改添加时间开发教程

发布者: 99225 | 发布时间: 2018-9-11 06:42| 查看数: 3868| 评论数: 1|帖子模式

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

第一步:
打开 admin/templates/article_info.htm
在第三行下面加入调用日历 JS




查找:

[tr]
        [td]{$lang.author}[/td]
        [td][/td]
      [/tr]


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



                 [tr]
        [td]{$lang.add_time}[/td]
        [td][/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']))
OK了!

最新评论

绿豆子 发表于 2022-7-10 19:22
免费网站代码

轻源码让程序更轻更快

QingYuanMa.com

工作时间 周一至周六 8:00-17:30

侵权处理

客服QQ点击咨询

关注抖音号

定期抽VIP

Copyright © 2016-2021 https://www.171739.xyz/ 滇ICP备13200218号

快速回复 返回顶部 返回列表