1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務時間:8:30-17:00
      你可能遇到了下面的問題
      關閉右側工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      smarty中常用方法有哪些-創(chuàng)新互聯(lián)

      本篇內(nèi)容主要講解“smarty中常用方法有哪些”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“smarty中常用方法有哪些”吧!

      創(chuàng)新互聯(lián)制作網(wǎng)站網(wǎng)頁找三站合一網(wǎng)站制作公司,專注于網(wǎng)頁設計,網(wǎng)站設計制作、網(wǎng)站設計,網(wǎng)站設計,企業(yè)網(wǎng)站搭建,網(wǎng)站開發(fā),建網(wǎng)站業(yè)務,680元做網(wǎng)站,已為上千余家服務,創(chuàng)新互聯(lián)網(wǎng)站建設將一如既往的為我們的客戶提供最優(yōu)質(zhì)的網(wǎng)站建設、網(wǎng)絡營銷推廣服務!

      具體如下:

      1. Smarty中foreach的index、iteration的使用

      .index包含當前數(shù)組索引,從零開始。

      index示例

      {* The header block is output every five rows *}
      {* 每五行輸出一次頭部區(qū)塊 *}
      
      {foreach from=$items key=myId item=i name=foo}
        {if $smarty.foreach.foo.index % 5 == 0}
         
        {/if}
        
      {/foreach}
      
      Title
      {$i.label}

      .iteration包含當前循環(huán)次數(shù),與index不同,從1開始,每次循環(huán)增長1。

      iteration和index示例

      {* this will output 0|1, 1|2, 2|3, ... etc *}
      {* 該例將輸出0|1, 1|2, 2|3, ... 等等 *}
      {foreach from=$myArray item=i name=foo}
      {$smarty.foreach.foo.index}|{$smarty.foreach.foo.iteration},
      {/foreach}

      2. smarty中section的嵌套使用

      示例1:

      $bookmarks = array('0' => array('name'=> 'n1', 'url'=>'url2'), '1' => array('name'=> 'n21', 'url'=>'url22'));
      $categories= array('0' => array('cate_id'=> 'n1', 'cate_name'=>'url2'), '1' => array('cate_id'=> 'n21', 'cate_name'=>'url22'));
      {section name='bm' loop=$bookmarks}
       Name:$bookmarks[bm].name
       URL:$bookmarks[bm].url
        {section name='cate' loop=$categories[bm]}
           $categories[bm][cate].cate_id
           $categories[bm][cate].cate_name
        {/section}
      {/section}
      ::::

      示例2:

      $lists = array();
      for(...){
        $oneList['dateTime'] = date("Y-m-d");
        $oneList['detailList'] = array();
        for(....){
          $oneList['detailList'][$j]['count'] = $onecout;
          $oneList['detailList'][$j]['title'] = $onetitle;
        }
        $lists[] = $oneList;
      }
      :::::
      {section name=loop loop=$lists}
        {$lists[loop].dateTime}
        {section name=loop2 loop=$lists[loop]["detailList"]}
          {$lists[loop]['detailList'][loop2].title}
          {$lists[loop]["detailList"][loop2].count}
        {/section}
      {/section}

      3. 其他常用關鍵字

      <{section loop= $varName[,start=$start,step=$setp,max=$max,$show=true]}>

          name: section的名稱,不用加$;
          $loop: 要循環(huán)的變量,程度中要使用assign對這個變量進行操作。
          $start: 開始循環(huán)的下標。默認為0;
          $step: 每次循環(huán)下標的增數(shù);
          $show : boolean型。決定是否對于這塊進行顯示。默認為true;

      <{section}>的屬性;

          index:循環(huán)下標。默認為0;
          index_prev:當前下標的上一個值,默認為-1;
          index_next:當前下標的下一個值,默認為1;
          first:是否為第一下循環(huán);
          last:是否為最后一個循環(huán);
          iteration:循環(huán)個數(shù);
          rownum:當前行號,iteration的別名;
          loop:最后一個循環(huán)號。Section的循環(huán)次數(shù);
          show:是否顯示;

      <{section loop=$News}>
         新聞編號:<{$News[loop].newID}>
         新聞內(nèi)容:<{$News[loop].newTitle}>
      <{sectionelse}>    I am sorry <{/section}>

      if用法:

      {if $list[row].name eq "1"}
        星期1
      {elseif $list[row].name=="2"}
        星期2
      {else}
        默認
      {/if}

      4. smarty 系統(tǒng)變量

      {* 顯示URL中的page值($_GET)http://www.example.com/index.php?page=foo *}
      {$smarty.get.page}
      {* 顯示來自一個表單的"page"變量($_POST['page'])*}
      {$smarty.post.page}
      {* 顯示COOKIE變量"username"的值($_COOKIE['username'])*}
      {$smarty.cookies.username}
      {* 顯示服務器變量"SERVER_NAME"($_SERVER['SERVER_NAME'])*}
      {$smarty.server.SERVER_NAME}
      {$smarty.server.PHP_SELF}
      {$smarty.server.SCRIPT_NAME}
      {* 顯示系統(tǒng)環(huán)境變量"PATH" *}
      {$smarty.env.PATH}
      {* 顯示PHP會話變量"id"($_SESSION['id'])*}
      {$smarty.session.id}
      {* 顯示變量"username",不論來自get/post/cookies/server/env *}
      {$smarty.request.username}
      $smarty}保留變量可以被用于訪問一些特殊的模板變量,以下是全部頁面請求變量。

      以下是訪問頁面請求變量諸如get,post,cookies,server,enviroment和session變量的例子. 例如{$smarty.server.SERVER_NAME}取得服務器變量,{$smarty.env.PATH}取得系統(tǒng)環(huán)境變量path,{$smarty.request.username}取得get/post/cookies/server/env的復合變量。

      {$smarty.now}變量用于訪問當前時間戳.
      可以用 date_format調(diào)節(jié)器格式化輸出. 例如{$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}

      {$smarty.const}
      你可以直接訪問PHP常量. 例如{$smarty.const._MY_CONST_VAL}

      {$smarty.capture}
      可以通過{capture}..{/capture}結構 截取的輸出可以使用{$smarty} 變量訪問.

      {$smarty.config}
      {$smarty}變量 可以訪問已經(jīng)加載的config變量.

      例如 {$smarty.config.foo}就可以表示 {#foo#}.

      {$smarty.section}, {$smarty.foreach}
      {$smarty} 變量可以訪問'section'和'foreach'循環(huán)的屬性.
      {$smarty.template}
      顯示當前被處理的模板的名字.
      {$smarty.version}
      顯示smarty模板的版本
      {$smarty.ldelim}
      顯示左分隔符
      {$smarty.rdelim}

      顯示右分隔符$smarty}保留變量可以被用于訪問一些特殊的模板變量,以下是全部頁面請求變量。

      以下是訪問頁面請求變量諸如get,post,cookies,server,enviroment和session變量的例子. 例如{$smarty.server.SERVER_NAME}取得服務器變量,{$smarty.env.PATH}取得系統(tǒng)環(huán)境變量path,{$smarty.request.username}取得get/post/cookies/server/env的復合變量。

      {$smarty.now}變量用于訪問當前時間戳.
      可以用 date_format調(diào)節(jié)器格式化輸出. 例如{$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}
      {$smarty.const}

      你可以直接訪問PHP常量. 例如{$smarty.const._MY_CONST_VAL}
      {$smarty.capture}
      可以通過{capture}..{/capture}結構 截取的輸出可以使用{$smarty} 變量訪問.
      {$smarty.config}
      {$smarty}變量 可以訪問已經(jīng)加載的config變量.
      例如 {$smarty.config.foo}就可以表示 {#foo#}.
      {$smarty.section}, {$smarty.foreach}
      {$smarty} 變量可以訪問'section'和'foreach'循環(huán)的屬性.
      {$smarty.template}
      顯示當前被處理的模板的名字.
      {$smarty.version}
      顯示smarty模板的版本
      {$smarty.ldelim}
      顯示左分隔符
      {$smarty.rdelim}
      顯示右分隔符

      到此,相信大家對“smarty中常用方法有哪些”有了更深的了解,不妨來實際操作一番吧!這里是創(chuàng)新互聯(lián)建站,更多相關內(nèi)容可以進入相關頻道進行查詢,關注我們,繼續(xù)學習!


      文章標題:smarty中常用方法有哪些-創(chuàng)新互聯(lián)
      地址分享:http://www.ef60e0e.cn/article/gdgjc.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        长宁县| 册亨县| 宁强县| 宁明县| 肥东县| 三原县| 鲁山县| 收藏| 鄂托克前旗| 晋宁县| 沾益县| 彭山县| 邵阳市| 华安县| 开鲁县| 北辰区| 蓝田县| 彰化市| 云安县| 界首市| 榆树市| 洛阳市| 西安市| 晴隆县| 凌云县| 化隆| 洛扎县| 伽师县| 宁明县| 阿克苏市| 新泰市| 娱乐| 武冈市| 鲁甸县| 宜章县| 砚山县| 姜堰市| 延长县| 酒泉市| 阳原县| 芷江|