<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # 表情輔助函數 表情輔助函數文件包含了一些讓你管理表情的函數。 > 重要 > 表情輔助函數已經廢棄,不建議使用。現在只是為了向前兼容而保留。 [TOC=2,3] ## [加載輔助函數](http://codeigniter.org.cn/user_guide/helpers/smiley_helper.html#id9) 該輔助函數通過下面的代碼加載: ~~~ $this->load->helper('smiley'); ~~~ ## [概述](http://codeigniter.org.cn/user_guide/helpers/smiley_helper.html#id10) 表情輔助函數用于將純文本的表情轉換為圖片,譬如::-) 轉換為?![smile!](http://codeigniter.org.cn/user_guide/_images/smile.png) 另外它還可以顯示一組表情圖片,當你點擊其中的某個表情時將會被插入到一個表單域中。 例如,如果你有一個博客并允許用戶提交評論,你可以將這組表情圖片顯示在評論的旁邊, 這樣用戶就可以點擊想要的表情,然后通過一點點的 Javascript 代碼,將該表情插入到 用戶的評論中去。 ## [可點擊的表情包教程](http://codeigniter.org.cn/user_guide/helpers/smiley_helper.html#id11) 這里是一個如何在表單中使用可點擊的表情包的示例,這個示例需要你首先下載并安裝表情圖片, 然后按下面的步驟創建一個控制器和視圖。 重要 開始之前,請先?[下載表情圖片](https://ellislab.com/asset/ci_download_files/smileys.zip)?然后將其放置到服務器的一個公共目錄,并打開?application/config/smileys.php?文件設置表情替換的規則。 ### [控制器](http://codeigniter.org.cn/user_guide/helpers/smiley_helper.html#id12) 在?**application/controllers/**?目錄下,創建一個文件 Smileys.php 然后輸入下面的代碼。 重要 修改下面的?[get_clickable_smileys()](http://codeigniter.org.cn/user_guide/helpers/smiley_helper.html#get_clickable_smileys "get_clickable_smileys")?函數的 URL 參數,讓其指向你的表情目錄。 你會發現我們除了使用到了表情庫,還使用到了?[表格類](http://codeigniter.org.cn/user_guide/libraries/table.html): ~~~ <?php class Smileys extends CI_Controller { public function index() { $this->load->helper('smiley'); $this->load->library('table'); $image_array = get_clickable_smileys('http://example.com/images/smileys/', 'comments'); $col_array = $this->table->make_columns($image_array, 8); $data['smiley_table'] = $this->table->generate($col_array); $this->load->view('smiley_view', $data); } } ~~~ 然后,在?**application/views/**?目錄下新建一個文件?**smiley_view.php**?并輸入以下代碼: ~~~ <html> <head> <title>Smileys</title> <?php echo smiley_js(); ?> </head> <body> <form name="blog"> <textarea name="comments" id="comments" cols="40" rows="4"></textarea> </form> <p>Click to insert a smiley!</p> <?php echo $smiley_table; ?> </body> </html> When you have created the above controller and view, load it by visiting http://www.example.com/index.php/smileys/ </body> </html> ~~~ ### [字段別名](http://codeigniter.org.cn/user_guide/helpers/smiley_helper.html#id13) 當修改視圖的時候,會牽扯到控制器中的 id 字段,帶來不便。為了解決這一問題, 你可以在視圖中給表情一個別名,并將其映射到 id 字段。 ~~~ $image_array = get_smiley_links("http://example.com/images/smileys/", "comment_textarea_alias"); ~~~ 將別名映射到 id 字段,可以使用 smiley_js 函數并傳入這兩個參數: ~~~ $image_array = smiley_js("comment_textarea_alias", "comments"); ~~~ ## [可用函數](http://codeigniter.org.cn/user_guide/helpers/smiley_helper.html#id14) get_clickable_smileys($image_url[,?$alias = ''[,?$smileys = NULL]]) 參數: * **$image_url**?(string) -- URL path to the smileys directory * **$alias**?(string) -- Field alias 返回: An array of ready to use smileys 返回類型: array 返回一個已經綁定了可點擊表情的數組。你必須提供表情文件夾的 URL , 還有表單域的 ID 或者表單域的別名。 舉例: ~~~ $image_array = get_clickable_smileys('http://example.com/images/smileys/', 'comment'); ~~~ smiley_js([$alias = ''[,?$field_id = ''[,?$inline = TRUE]]]) 參數: * **$alias**?(string) -- Field alias * **$field_id**?(string) -- Field ID * **$inline**?(bool) -- Whether we're inserting an inline smiley 返回: Smiley-enabling JavaScript code 返回類型: string 生成可以讓圖片點擊后插入到表單域中的 JavaScript 代碼。如果你在生成表情鏈接的時候 提供了一個別名來代替 id ,你需要在函數中傳入別名和相應的 id ,此函數被設計為 應放在你 Web 頁面的 部分。 舉例: ~~~ <?php echo smiley_js(); ?> ~~~ parse_smileys([$str = ''[,?$image_url = ''[,?$smileys = NULL]]]) 參數: * **$str**?(string) -- Text containing smiley codes * **$image_url**?(string) -- URL path to the smileys directory * **$smileys**?(array) -- An array of smileys 返回: Parsed smileys 返回類型: string 輸入一個文本字符串,并將其中的純文本表情替換為等效的表情圖片,第一個參數為你的字符串, 第二個參數是你的表情目錄對應的 URL 。 舉例: ~~~ $str = 'Here are some smileys: :-) ;-)'; $str = parse_smileys($str, 'http://example.com/images/smileys/'); echo $str; ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看