巧用ecshop smarty中iteration

ecshop中的模板技术确实不错,ecshop的smarty也写的很好,foreach标签是ecshop中smarty用的最多的一个标签了。而foreach中的iteration非常有用。    iteration其实是foreach循环中的下标,而且从1开始.直接循环。所以在ecshop销售排行中,很多人用这个来区分销售的图标.他是foreach下name的键值.{foreach name=top_goods from=$top_goods item=goods}
   <meta http-equiv=”Content-Type” content=”text ml; charset=gbk”>
<div class=”mod2″>
<h1><span class=”left”></span><span class=”right”></span>销售排行</h1>
<!– {foreach name=top_goods from=$top_goods item=goods}–>
  <ul class=”top10 clearfix”>
<li><img src=”../images/top_{$smarty.foreach.top_goods.iteration}.gif” class=”iteration” />
<!– {if $smarty.foreach.top_goods.iteration<2}–>
      
    <table width=”185″ border=”0″>
  <tr>
    <td><a href=”{goods.url}” target=”_blank”><img src=”{goods.thumb}” alt=”{$goods.name|escape:html}” class=”topimg” height=”80px” width=”80px” /></a></td>
    <td>售价:<font class=”f1″>{$goods.price}</font></td>
  </tr>
</table>
   
     
     
<!– {/if} –> 
       <{if $smarty.foreach.top_goods.iteration<4}class=”iteration1″{/if}>
      <a href=”{goods.url}” title=”{goods.name|escape:html}” target=”_blank”>{$goods.short_name}</a><br />
      
      < >
   <div></div>
    </ul>
  <!– {/foreach} –>
</div>
    这个是ecshop销售排行的模板,他通过巧妙使用foreach来实现了图标的对应.><img src=”../images/top_{$smarty.foreach.top_goods.iteration}.gif” class=”iteration” />

ShopNC B2B2C最新版 隐藏SHOP和去除shop方法

方法一:shopwwi.com运维提供
这个方法我想大家都知道!就是传统的官方所教导的方法!就是域名绑定目录法!shoshopwwi.com运维提供pwwi.com运维提供
1.将www.shopwwi.com绑定根目录下的shop目录!shopwwi.com运维提供shopwwi.com运维提供
2.根目录可以用根域名shopwwi.com绑定!shopshshopwwi.com运维提供opwwi.com运维提供wwi.com运维提供
3.其他文件夹也绑定*.shopwwi.com!前缀自己想!sshopwwi.com运维提供hopwwi.com运维提供
4.绑定完目录之后!然后修改config.ini.php里的对应绑定域名shopwwi.com运维提供shopwwi.com运维提供
此为方法一:有点确实去除了shop!但是当用二级域名访问店铺的时候!依然后缀会出现shop!无解!sshopwwi.com运维提供hopwwi.com运维提供
注意:shopwwi.com换成自己的域名!不要挑刺!shopwwi.com运维提供
shopwwi.com运维提供
方法二:
shopwwi.com运维提供
此方法修改起来较费时费力!因此我尽量说的详细一点!shopwwi.com运维提供
shopwwi.com运维提供
为了能够使www域名能够够完善的使用!请按以下步骤一步一步来!shopwwi.com运维提供
shopwwi.com运维提供
1.转移shop下目录文件至根目录shopwwi.com运维提供
2.修改config.ini.php里的shop绑定域名更改为无shop目录shopwwi.com运维提供
3.将原始根目录的index.php更改为main.php文件名自己定!并修改index.php代码(index.php=main.php的情况下按以下修改!你改成啥main.php就是啥):shopwwi.com运维提供

  1. $site_url = strtolower(‘http://’.$_SERVER[‘HTTP_HOST’].substr($_SERVER[‘PHP_SELF’], 0, strrpos($_SERVER[‘PHP_SELF’], ‘/index.php’)).’/shop/index.php’);
  2. @header(‘Location: ‘.$site_url);

复制代码

修改为shopwwi.com运维提供

  1. $site_url = strtolower(‘http://’.$_SERVER[‘HTTP_HOST’].substr($_SERVER[‘PHP_SELF’], 0, strrpos($_SERVER[‘PHP_SELF’], ‘/main.php’)).’/index.php’);
  2. @header(‘Location: ‘.$site_url);

复制代码

4.打开shop下的index.php也就是现在转移到跟目录下的index.php找到以下代码

  1. if (!@include(dirname(dirname(__FILE__)).’/global.php’)) exit(‘global.php isn\’t exists!’);

复制代码

修改为

  1. if (!@include(dirname(__FILE__)).’/global.php’) exit(‘global.php isn\’t exists!’);

复制代码


5.是不是觉得很简单 想问我还有没有其他操作的 我想说的是 没了!就这些
shop

php中实现可以返回多个值的函数实例

在python和golang中都有一个函数同时返回多个值的方法,其实php也可以,但相比python和golang要稍微麻烦一点,下面是一个简单的演示范例,这里用到了list函数

<?php
  function retrieve_user_profile() {
   user[] = "Jason";
   user[] = "jb51.net";
   user[] = "English";
   returnuser;
  }
  list(name,email,language) = retrieve_user_profile();
  echo "Name:name, email: email, preferred language:language";
?>