[WordPress] 外掛分享: Dropdown Content

首頁外掛目錄 › Dropdown Content
⚠ 此外掛已下架 — 不再更新維護,建議勿安裝。
600+
安裝啟用
★★★★★
5/5 分(5 則評價)
3463 天前
最後更新
問題解決
WordPress 4.0+ v1.0.2 上架:2016-09-26

內容簡介

使用短代碼來定義下拉式表單欄位,並使用短代碼來定義當選擇特定項目時顯示的內容區塊。

用法

要在文章中添加內容下拉式清單,您可以從 TinyMCE 編輯器中選擇內容下拉式清單圖示,或手動輸入短代碼。

[dropdown name="controlName" class="customClassName"] - `name` 和 `class` 都是可選的;`name` 將默認為 `dropdown-content`

`name` 用於識別此下拉式清單針對哪些內容區塊;如果頁面上只有一個下拉式清單,則為選擇性的;如果頁面上有多個下拉式清單,則每個都需要一個唯一的名稱
`class` 可以是以空格分隔的類名列表,或只是一個類名

只有 `dropdown-option` 短代碼可以在這個短代碼內

[dropdown-option value=”someValue”] – `value` 欄位在技術上是可選的,但如果此選項的目的是使內容塊可見,則為必需的。

必須在一個 `[dropdown]` 短代碼內

[dropdown-content name=”controlName” value=”someValue”] – 如果 `name` 符合下拉式清單的名稱,並且 `value` 符合該下拉式清單中某個選項的值,那麼當選擇該特定選項時,將顯示此內容。

同樣,name 是可選的,但必須匹配 `[dropdown]` 名稱(也預設為 `dropdown-content`)

必須是頁面上的任何位置

範例

複製並貼上以下內容以查看插件的作用

[dropdown]
[dropdown-option]選擇一個...[/dropdown-option]
[dropdown-option value=”option1″]第一個選項[/dropdown-option]
[dropdown-option value=”option2″]第二個選項[/dropdown-option]
[/dropdown]

[dropdown-content value=”option1″]第一個選項的內容。

[dropdown-content value=”option2″]第二個選項的內容。

這些都是使用插件的預設值。讓我們做一些變更。

[dropdown]
[dropdown-option value=”option1″]第一項[/dropdown-option]
[dropdown-option value=”option2″ default=true]第二項[/dropdown-option]
[dropdown-option value=”option3″]第三項[/dropdown-option]
[/dropdown]

您會注意到下面第二個選項會以您選擇為預設顯示。

[dropdown-content value=”option1″]第一個選項的一些不同內容。

[dropdown-content value=”option2″]第二個選項的一些不同內容。

[dropdown-content value=”option3″]第三個選項的一些不同內容。

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.0.2) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Dropdown Content」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

Use a shortcode to define a drop-down form field, and shortcodes to define blocks of content that will be displayed when a specific entry is selected.
Usage
To add a content dropdown to a post, you can either select the Content Dropdown icon from the TinyMCE editor, or enter the shortcodes manually.
[dropdown name="controlName" class="customClassName"] - both `name` and `class` are optional; `name` will default to `dropdown-content`

the name is used to identify which content sections are targetted by this dropdown; if there is only one dropdown on a page, it is optional; if there are multiple dropdowns on a page, each will need a unique name
class can be a space-separated list of class names, or just a single class name

only [dropdown-option] shortcodes may be inside this shortcode
[dropdown-option value=”someValue”] – the value field is technically optional, but is required if this option is meant to make a content block visible

must be inside a [dropdown] shortcode
[dropdown-content name=”controlName” value=”someValue”] – if the name matches a dropdown name, and the value matches the value of an option within that dropdown, then this content will be displayed when that specific option is selected.

again, name is technically optional, but must match a [dropdown] name (also defaults to dropdown-content)

value is required, and must match a value for a [dropdown-option]
can be anywhere on the page

Example
Copy and paste the following content to see the plugin in action
[dropdown]
[dropdown-option]Select one…[/dropdown-option]
[dropdown-option value=”option1″]First option[/dropdown-option]
[dropdown-option value=”option2″]Second Option[/dropdown-option]
[/dropdown]
[dropdown-content value=”option1″]Content for the first option.[/dropdown-content]
[dropdown-content value=”option2″]Content for the second option.[/dropdown-content]
Those were all using the default values from the plugin. Let’s change it up a bit.
[dropdown]
[dropdown-option value=”option1″]The First[/dropdown-option]
[dropdown-option value=”option2″ default=true]The Second[/dropdown-option]
[dropdown-option value=”option3″]The Third[/dropdown-option]
[/dropdown]
You’ll notice below that the second option will be displayed by default for you.
[dropdown-content value=”option1″]Some different content for the second first option.[/dropdown-content]
[dropdown-content value=”option2″]Some different content for the second second option.[/dropdown-content]
[dropdown-content value=”option3″]Some different content for the second third option.[/dropdown-content]

延伸相關外掛

文章
Filter
Mastodon