ecshop生成静态网站地图sitemap.html

ecshop只有生成xml格式的网站地图,如果要做一个html格式的就只有自己做了,这里只给出关键代码,其他获取栏目的代码就不拿出来了。

//商品分类
    $categories = get_categories_tree();
    $bigcatestr = "";
    foreach($categories as $key=>$cat)
    {
      if ($cat['id']==2)
      {
        $bigcatestr .= "<li><a href='diy.php'>".htmlspecialchars($cat['name'])."</a></li>";
      }
      else
      {
         $bigcatestr .= "<li><a href='".$cat['url']."'>".htmlspecialchars($cat['name'])."</a></li>";
      }
    }



clear_cache_files();    // 清除缓存


    //从模板中读取sitemap.dwt,文件位于data文件夹下
    $file = $_SERVER['DOCUMENT_ROOT'].'/data/sitemap.dwt';


    $fp = fopen ($file,"r");
    $content = fread ($fp,filesize ($file));
    $content = str_replace ("{my_cart_goods_count}", 1, $content);
    $content = str_replace ("{my_cart_list}", "<dd>ssss</dd>", $content);
    $content = str_replace ("{category_top}", $categorylist1, $content);
    $content = str_replace ("{bigcate}", $bigcatestr, $content);
    $content = str_replace ("{left_help}", $leftmenustr, $content);
    $content = str_replace ("{sitemap_goods}", $sitemap_goods, $content);
    $content = str_replace ("{sitemap_article}", $sitemap_article, $content);
    $content = str_replace ("{sitemap_help}", $sitemap_help, $content);
    $content = str_replace ("{helps}", $helpsstr, $content);
    $filename = $_SERVER['DOCUMENT_ROOT']."/sitemap.html";
    $handle = fopen ($filename,"w"); //打开文件指针,创建文件
    if (!is_writable ($filename)) {
    die ("文件:".$filename."不可写,请检查其属性后重试!");
    }
    if (!fwrite ($handle,$content)){ //将信息写入文件
    die ("生成文件".$filename."失败!");
    }
    fclose ($handle); //关闭指针
    die ("创建文件".$filename."成功!");

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值