
內容簡介
CSV to SortTable 插件非常適合想要在 WordPress 網站上展示試算表資訊的使用者。此插件可用於顯示產品目錄、庫存清單、排行榜或任何存儲在 CSV 檔案中的內容。
使用方式
使用以下簡碼在任何頁面或文章中插入可排序的表格:
[csv src=http://example.com/myfile.csv]
結果將是一個漂亮、語意正確的 HTML 表格,其內容為您的檔案。
選用功能
此插件自動為您執行一些動作,全部可禁用:
新增了一些 CSS 以使表格顯示得更好看。
將圖片檔案 URL 轉換為可點擊的圖片連結。
將某些檔案 URL 轉換為可點擊的檔案類型圖示 (.doc、.pdf、.ppt、.xls、.zip)。
使用 disable 簡碼屬性就可以停用任何其中一些功能:
[csv src=http://example.com/myfile.csv disable=css]
[csv src=http://example.com/myfile.csv disable=icons,images]
[csv src=http://example.com/myfile.csv disable=all]
第一個範例僅停用插件 CSS;第二個範例會停用檔案類型圖示和影像連結;而第三個範例會停用所有選用功能。使用逗號分隔的清單 (不含空格) 停用任何組合。
表格 ID
想要為表格指定唯一的 ID 嗎?使用 id 簡碼屬性:
[csv src=http://example.com/myfile.csv id=my_data_table]
上面的範例會給 <table> 元素新增一個 id 屬性為 my_data_table。
分組類別
假設您有一個具有三個欄位的表格:物品、描述和類型。您希望所有相同類型的表格列具有相同的類別,這樣就可以使用 CSS 以不同的顏色加以凸顯,或使用 JavaScript 一次性修改它們。
可藉由將欄位編號指定為 group 簡碼屬性完成此操作:
[csv src=http://example.com/myfile.csv group=3]
結果會根據第三個欄位的值,指定每個表格列的特殊類別。
排序選項
預設情況下,表格資料以字母順序排序。如果您希望對欄位進行數字或日期排序,或在某些欄位上禁用排序,則可以使用以下簡碼屬性:
[csv src=http://example.com/myfile.csv number=2]
[csv src=http://example.com/myfile.csv date=3]
[csv src=http://example.com/myfile.csv unsortable=4,5,6]
值可以是單個欄位編號,也可以是逗號分隔的多個欄位編號清單 (不含空格!)。
相對檔案路徑
如果 src 值是相對路徑 (以斜線開頭),則插件將參照 WP-Admin > 設定 > 一般 中定義的「網站位址 (URL)」:
[csv src=/mydata/data.csv]
上面的範例會參照 http://example.com/mydata/data.csv。
資料陣列篩選器
您可能希望在匯入 CSV 資料後,但在呈現 HTML 表格之前,對這些資料進行操作。為此,請使用此篩選器:
csv_to_sorttable_data_array
以下是如何使用資料陣列篩選器的一些程式碼範例:
移除第一列(函數)
新增標題列(函數)
外掛標籤
開發者團隊
原文外掛簡介
CSV to SortTable is great for anyone who wants to display information from a spreadsheet on a WordPress website. This plugin can be used to display product catalogs, inventory lists, leaderboards or anything else that can be stored in a CSV file.
How To Use
Insert a sortable table into any page or post using this shortcode:
[csv src=http://example.com/myfile.csv]
The result will be a beautiful, semantically-correct HTML table populated with the contents of your file.
Optional Features
This plugin automatically does a few things for you, all of which can be disabled:
Adds some CSS to make the table look nice.
Converts image file URLs into clickable image links.
Converts certain file URLs into clickable file-type icons (.doc, .pdf, .ppt, .xls, .zip).
To disable any of these features, use the disable shortcode attribute:
[csv src=http://example.com/myfile.csv disable=css]
[csv src=http://example.com/myfile.csv disable=icons,images]
[csv src=http://example.com/myfile.csv disable=all]
The first example would disable only the plugin CSS; the second would disable both the file-type icons and image links; and the third would disable all optional features. Disable any combination using a comma-separated list (no spaces!).
Table ID
Want to give your table a unique ID? Use the id shortcode attribute:
[csv src=http://example.com/myfile.csv id=my_data_table]
The above example would give the
