Coder Social home page Coder Social logo

bzerangue / xml_selectbox Goto Github PK

View Code? Open in Web Editor NEW

This project forked from symphonists/xml_selectbox

1.0 2.0 1.0 109 KB

[Symphony 2] A Select Box field that can be populated by the contents of an XML document

Home Page: http://symphony-cms.com/download/extensions/view/27114/

PHP 100.00%

xml_selectbox's Introduction

Field: XML Select Box

Installation

  1. Download and upload the 'xml_selectbox' folder to your Symphony 'extensions' folder.
  2. Enable the extension by selecting "Field: XML Select Box" in the list and choose Enable from the with-selected menu, then click Apply.
  3. You can now select the "XML Select Box" field when creating a section.

Usage

This field is as generic as possible so that it can support many uses. For example:

  • any list of items that are too long for the Static Items value of a normal Select Box field (e.g. countries/regions)
  • a list of days of the week, or months of the year
  • a list of your Flickr sets or Picassa albums for associating with Symphony entries
  • availability dates from your Google Calendar
  • a list of your Delicious tags so you can maintain a shared taxonomy between your bookmarks and your blog

Choosing an XML source

XML sources can be loaded into the field in three ways using the "XML Location" option:

  1. Using the commonly-used XML files that come with the field. Simply enter the name of the XML file, e.g. countries_en.xml
  2. Referencing a local XML file in your Symphony site. Prefix the XML path with a forward-slash to locate a file inside your web root e.g. /workspace/xml/foo.xml or /assets/bar.xml
  3. Use the URL of a valid XML source e.g. http://nick-dunn.co.uk/rss/. This string can contain params {$root} and {$workspace} for local URLs.

Selecting data from the XML

The "Item" option accepts an XPath expression. Each selected node is used to create a new <option> in the selectbox. The value attribute (optional) and text value of the <option> are evaluated as XPath in the same way, using the "Item" as the context node.

By means of example, you would use this configuration for a list of countries (XML file included with this extension):

XML Location: countries_en.xml
Item: //country
Value: @abbr
Label: text()

Caching

Caching of the XML file is applied only when using a URL as the "XML Location". Local XML files are not cached. If your feed changes infrequently, set the cache interval high to perhaps several hours, days or even weeks. If the data changes frequently then use a lower value (1 minute minimum) but be aware of the performance implications for your users.

The XML is parsed both to build the selectbox in the backend and when writing its value to Data Source XML, so a high cache interval is recommended.

Choose Field Type (Select Box or Autocomplete)

With inspiration from Craig Zheng's referencelink field that employs field types selectbox and autocomplete, we added the autocomplete functionality to easily add from your existing XML.

xml_selectbox's People

Contributors

nickdunn avatar bzerangue avatar tonyarnold avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.